Some mobile phone providers add compression parameters in their Accept request Headers. This might cause the application to respond with HTML instead of JSON.
I recently came across the following format for application/json:
HEADER KEY: HTTP_ACCEPT
HEADER VALUE: application/json,/;q=0.001
The rails application will translate this Accept header to html/text
HEADER KEY: action_dispatch.request.formats
HEADER VALUE: text/html
The value application/json for HTTP_ACCESS should give a json callback.
I fixed the issue in my application by forcing the request format to application/json in the ApplicationController. But a more appropriate solution would be welcome.
class ApplicationController < ActionController::Base
request.format = 'json'.to_sym if ((request.env["HTTP_ACCEPT"]).include? "application/json")
But proper handling would be better if the application/json,/;q=0.001 syntax is correct.
@steveklabnik didn't you fix this in a different commit?
What I did was add support for non-q parameters (8c4b3a4), so yes, I think that would take care of it.
@Antek-drzewiecki, is this still an issue for you on master?
I was running rails 3.0.9. Ill test it on the master branch on monday.
@Antek-drzewiecki cool. If there's still an issue on 3.2 or master, let me know, and re-open. Since I'm pretty sure that I fixed this, I'm gonna give it a close.