Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fixes issue #5660: Failsafe exception returns text/html and text/plain. #6981

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants
Contributor

jeyb commented Jul 6, 2012

If the request format is text/html then return the existing failsafe
response. For all other formats return text/plain.

The original issue points out to return JSON at the appropriate time,
however as @wycats pointed out, it's often better to return text/plain.

Fixes issue #5660: Failsafe exception returns text/html and text/plain.
If the request format is text/html then return the existing failsafe
response. For all other formats return text/plain.

The original issue points out to return JSON at the appropriate time,
however as @wycats pointed out, it's often better to return text/plain.
Contributor

josevalim commented Jul 6, 2012

Thanks. The issue with this approach is that the likelihood that HTTP_ACCEPT will be simply text/html is very low. Browsers usually send a lot of gibberish. @wycats, any idea?

Contributor

jeyb commented Jul 6, 2012

@josevalim Very good point, should I go for regular expressions or do you have another idea in mind?

Member

steveklabnik commented Jul 6, 2012

Nice.

Yeah a regex should do it, I'd think.

Contributor

josevalim commented Jul 6, 2012

Here is the code that does it today:

https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/mime_negotiation.rb#L54

However, I don't think we should do anything complex in this area because we are already in the failsafe stage. Notice that this code should never, never be rendered (in theory).

Rely on existing checks for response format.
Basic string comparison can fail as browsers don't send text/html
but other parameters as well.

@jeyb jeyb closed this Oct 25, 2012

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