mikeobrien / WcfRestContrib

The WCF REST Contrib library adds additional functionality to the current WCF REST implementation.
MIT License
49 stars 18 forks source link

I modified WebFormatterFactory to support Content-Type with character set #15

Closed tuesdaysiren closed 12 years ago

tuesdaysiren commented 12 years ago

I notice that Firefox Content-Type is "text/json; charset=UTF-8" which result in the WebFormatterFactory always return the WebFormatter for the default MimeType since is trying to find the formatter for "text/json; charset=UTF-8". Anyway, this is a quick fix for that particular problem.

mikeobrien commented 12 years ago

Conrad,

Thanks for catching this and sending a pull request! I ended up implementing it a little differently but should fix the issue:

    public IWebFormatter CreateFormatter(string contentType)
    {
        string resolvedContentType;
        if (contentType.Contains(";")) contentType = contentType.Split(';').First();
        return CreateFormatter(new [] { contentType }, out resolvedContentType);
    }

Let me know if this will work.

Thanks again,

m

tuesdaysiren commented 12 years ago

That looks good to me. Thanks.

mikeobrien commented 12 years ago

Ok, just committed and deployed the nuget. You should be good to go.

Thanks!

m

On Tue, Feb 14, 2012 at 2:09 AM, Conrad Tran < reply@reply.github.com

wrote:

That looks good to me. Thanks.


Reply to this email directly or view it on GitHub: https://github.com/mikeobrien/WcfRestContrib/pull/15#issuecomment-3956211