HTTP_ACCEPT doesn't allows extra attributes for MIME TYPE application/json #3390

antek-drzewiecki opened this Issue Oct 21, 2011 · 4 comments


None yet

3 participants


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 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
before_filter :foo
def foo
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?

Ruby on Rails member

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.

Ruby on Rails member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment