Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Negotiation returns xml instead of json #746

Closed
grahamrhay opened this issue Sep 13, 2012 · 9 comments
Closed

Negotiation returns xml instead of json #746

grahamrhay opened this issue Sep 13, 2012 · 9 comments

Comments

@grahamrhay
Copy link
Contributor

I'm making a request to a Nancy (0.12.0) service (using jQuery.ajax), but getting xml back instead of json.

The module returns:

Negotiate
      .WithModel(menuRepresentation)
      .WithCacheHeaders(products.First(), UntilMidnight());

(see Restbucks-on-Nancy -> /menu)

When I debug, my accept headers are:

application/json, 1
text/javascript, 1
&
/; q=0.01, 1

But BuiltInAcceptHeaderCoercions thinks my browser is stupid (sad face), and replaces them with text/html. I'm using Chrome 21.0.1180.89.

Am I missing something?

@grahamrhay
Copy link
Contributor Author

I removed that convention in my bootstrapper, and Robert is now my father's brother.

@thecodejunkie
Copy link
Member

@grahamrhay did you format your accept headers in your post? They don't look valid to me. Also Chrome 21.0.1180.89 m requests HTML using

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8

on my machine.

I do think there is an issue (i.e the StupidBrowser detection is too basic) and will probably remove it until we've improved it, but I'd like to reproduce the issue on my machine =)

@grahamrhay
Copy link
Contributor Author

Hmm, I copied and pasted those from the debugger. I'll get you the original header tomorrow.

This was from a jQuery ajax request (via Backbone). I tried setting the accepts and/or dataType options:

http://api.jquery.com/jQuery.ajax/

but it didn't make any difference.

@thecodejunkie
Copy link
Member

Thank you

If you get a chance then you can capture the traffic using Fiddler

On Thu, Sep 13, 2012 at 8:54 PM, Graham Hay notifications@github.comwrote:

This was from a jQuery ajax request (via Backbone). I tried setting the
accepts and/or dataType optio

@grahamrhay
Copy link
Contributor Author

First thing tomorrow! Thanks :)

@grahamrhay
Copy link
Contributor Author

Accept: application/json, text/javascript, /; q=0.01

@grahamrhay
Copy link
Contributor Author

Hmm, there should be some stars at the end of that #formatting_fail

@thecodejunkie
Copy link
Member

Is Chrome sending that?

On Fri, Sep 14, 2012 at 10:16 AM, Graham Hay notifications@github.comwrote:

Hmm, there should be some stars at the end of that #formatting_fail


Reply to this email directly or view it on GitHubhttps://github.com//issues/746#issuecomment-8554465.

@grahamrhay
Copy link
Contributor Author

That's a bit of a philosophical question :)

I have a client-side js app (backbone + jQuery) that's open in Chrome. It's making a request to the Nancy backend using jQuery.ajax(). So is Chrome making the request? Yes and no, I guess.

The user agent is AppleWebKit blah, which is why my browser is "stupid". (And you can't change that for an ajax request :).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants