Adding support for content negotiation.

This change consists of :
1. Conneg based on request headers, supports the following 3 scenarios:
	a. ContentType property on ObjectResult set to null or is empty.
	b. ContentType property on ObjectResult set to a single content type.
	c. ContentType property on ObjectResult set to multiple content types.

2. Parsing Helpers, comparers and extensions for comparing various http headers.
3. Tests.

Open workitems:
1. Remodel JsonResult and ContentResult to be a derivation of ObjectResult.
2. Add support for acceptcharset headers.
3. Produces Content Attribute.
4. Sample for adding a result filter for adding a custom formatter to the collection.
It's already supported. You can write a filter and apply whatever formatter you want, can you try it out?

-----Original Message-----
From: "Kiran Challa" <notifications@github.com>
Sent: ‎7/‎19/‎2014 10:04 AM
To: "aspnet/Mvc" <Mvc@noreply.github.com>
Cc: "Yishai Galatzer" <yishai_galatzer@yahoo.com>
Subject: Re: [Mvc] Adding support for content negotiation. (#813)

In src/Microsoft.AspNet.Mvc.Core/Formatters/StringWithQualityHeaderValueComparer.cs:
> +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
> +
> +using System;
> +using System.Collections.Generic;
> +using Microsoft.AspNet.Mvc.HeaderValueAbstractions;
> +
> +namespace Microsoft.AspNet.Mvc
> +{
> +    /// <summary>
> +    /// Implementation of <see cref="IComparer{T}"/> that can compare content negotiation header fields
> +    /// based on their quality values (a.k.a q-values). This applies to values used in accept-charset, 
> +    /// accept-encoding, accept-language and related header fields with similar syntax rules. See 
> +    /// <see cref="MediaTypeWithQualityHeaderValueComparer"/> for a comparer for media type 
> +    /// q-values.
> +    /// </summary>
> +    internal class StringWithQualityHeaderValueComparer : IComparer<StringWithQualityHeaderValue>
We need a way to expose the algorithm to enable scenarios where users would want to con-neg for Accept-Encoding header(ex: Accept-Encoding: gzip, deflate;q=0.8) in case we do not support this out of the box...i.e a user should be able to run the algorithm to find out the encoding and do the compression himself...
Currently in Web API we do not provide this and so wondering if we can fix this...
—
Reply to this email directly or view it on GitHub.