Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

406 Unacceptable received for something the Accept header has said it can take

#5991

I have a "build your own feed" kind of HTML form which POSTs to a controller action which can only return ATOM:

respond_to :atom
.
.
respond_with(@articles = Article.paged_since(@date, params[:path], params[:page], params[:include_deleted]))

The browser's Accept header is Firefox's default:

"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"

Unfortunately, posting to this action yields "406 Unacceptable" despite the fact the browser has said we can accept anything and we have an ATOM representation ready to go (this used to work in 2.3.5 - I've hit this apropos of upgrading to 3.0.3). I think this is an error - do people agree? It seems to be related to the following ticket:

#3541 Content Negotiation Regression

Before I start looking at how to be a contributor, is there anything obvious to anyone else that I've missed?

Cheers.

Reported by Russell Garner · November 17th, 2010 @ 11:31 AM

State: wontfix
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Russell Garner
  2. Russell Garner
    Russell Garner

    Attached 5991_tests.patch to demonstrate.

    November 17th, 2010 @ 05:51 PM

  3. José Valim
    José Valim
    • State changed from new to wontfix
    • Importance changed from to Low

    Yes, but this can't be fixed. Some browsers (cof cof IE) are really retarded when sending accept headers in the sense it may pass image/png or atom with higher priority than text/html. So rails tries to detect everything that looks like a bad browser request and defaults it to HTML. sorry, but You will need to pass :format => :atom as option to form_for or ensure in other way .atom is present at the end of the URL.

    November 19th, 2010 @ 10:31 AM

  4. Russell Garner
    Russell Garner

    If I found a way to make the above tests pass in addition to everyone else's, would you consider a patch? I'm actually hacking the request.format = :atom in the controller action at the moment, but I don't believe serving a 406 when any agent (browser or otherwise) has said they can accept anything and there are formats there waiting is good HTTP. We're letting bad browsers like (cough cough ;)) IE dictate good HTTP-related server practice.

    November 19th, 2010 @ 10:56 AM

  5. José Valim
    José Valim

    Yes, if you find a way to circumvent the issue, a patch is welcome. :)

    November 19th, 2010 @ 11:53 AM