This project is archived and is in readonly mode.
Internet Explorer Accept header
Reported by Manfred Stienstra | September 21st, 2009 @ 01:37 PM | in 2.3.10
Internet Explorer sends a rather retarded accept header, this causes Rails to respond with a whole slew of mime types before the sensible defaults: HTML and XML. For example:
repond_to do |format|
format.html
format.jpg do
send_file @photo.public_path, :type => 'image/jpeg'
end
end
Will return the JPEG instead of the HTML version on a regular request.
Attached is a patch which prepends HTML and XML to ActionController::Request#accepts when the user agent suggests Internet Explorer.
Comments and changes to this ticket
-
Manfred Stienstra September 22nd, 2009 @ 08:56 AM
- Assigned user set to josh
Some examples of people running into this problem, primarily with serving XML feeds.
http://log.maniacalrage.net/post/56019689/tip-avoid-ie-issues-with-...
http://ianma.wordpress.com/2009/05/06/ruby-on-rails-respond_to-bug-...
http://garrickvanburen.com/archive/workaround-for-ie-overly-accepti...
http://info.michael-simons.eu/2007/08/06/rails-respond_to-method/ -
josh September 22nd, 2009 @ 04:28 PM
- State changed from new to open
- Milestone changed from 2.x to 2.3.6
- Assigned user changed from josh to Yehuda Katz (wycats)
Ouch!
+1 to apply.
I known Yehuda made some changes to Accepts in 3.x so I'm not sure if its affected as well.
Do you think something similar should be applied to Rack core?
-
Manfred Stienstra September 22nd, 2009 @ 10:16 PM
There is nothing in Rails 3 addressing this issue as far as I can see. I don't think this belongs in Rack, it's coupled with the way Rails does content negotiation.
-
Yehuda Katz (wycats) September 24th, 2009 @ 05:50 AM
The fix in 3.0 is to reject Accept header usage if more than one MIME is specified.
This means that:
Accept: text/html
will work, but:
Accept: rather/retarded, ie/header
will fall back to text/html.
-
josh September 24th, 2009 @ 05:51 AM
- Assigned user changed from Yehuda Katz (wycats) to josh
-
josh September 24th, 2009 @ 05:52 AM
- Assigned user changed from josh to Michael Koziarski
Koz, can you weigh in.
(Sorry for all the handoffs)
-
Manfred Stienstra September 26th, 2009 @ 12:08 AM
- State changed from open to committed
-
Michael Koziarski September 29th, 2009 @ 04:18 AM
fwiw, this is why I added use_accept_header = false. It's a nice science experiment, but the header's basically junk in the wild.
-
Nazgum January 5th, 2010 @ 05:05 PM
I tested applying this patch to rails 2.3.5 and this causes Internet Explorer to fail to respond to certain requests, for example:
def update_chat
@shouts = Shout.recentrespond_to do |format|
format.js
end end
This method, which only responds to javascript, fails with Internet Explorer once this patch is applied, as Internet Explorer responds to the first mime type, which is text/html with this patch, which does not exist in this method..
-
Manfred Stienstra January 7th, 2010 @ 08:00 AM
- State changed from committed to open
The patch was applied and reverted for specifically that reason. I guess we should reopen it and take another look.
-
Gareth Adams March 8th, 2010 @ 04:38 PM
Could this be improved by adopting some kind of qs (quality of source) parameter to the format.* call, in the same way as Apache's content negotiation works?
repond_to do |format| format.html format.jpg :qs => 0.8 do send_file @photo.public_path, :type => 'image/jpeg' end end
You would have to ensure that
- A MIME type match by extension would automatically match its exact format block - A request without an extension would be matched by a q/qs algorithm like that in Apache's content negotiation - Suitable default qs values were set for different MIME types to reflect that a) Rails prefers serving HTML documents b) Some browsers aren't very good at specifying their Accept headerBy this logic, a UA wanting to get a non-HTML response to an extensionless URI would have to either
- Supply a qFor example, Firefox supplies a different Accepts header for resources loaded through an tag
Is this heading in the wrong direction? It seems to me that the Accept header is at most a guideline, so there shouldn't be any problem with using our own values to fudge the browser's requested quality values. The only problem would be doing the maths to work out the best possible 'fudge' values
-
Rohit Arondekar June 17th, 2010 @ 06:38 AM
Any updates to this ticket? Is somebody working on a new patch?
-
Jeremy Kemper August 30th, 2010 @ 02:28 AM
- Milestone changed from 2.3.9 to 2.3.10
- Importance changed from to Medium
-
mikhailov September 4th, 2010 @ 03:40 PM
I have the same issue, but "IE Accept header related bugs" been fixed be remove this chunk of js code:
$("form").submit(function(){$('input[type=submit]').attr('disabled', 'disabled'); return true;
});
It's weird for me, because I was looking for an issue in server-side code.
please be ensure that all is ok with your client-side scripts. -
sunkencity October 19th, 2010 @ 02:37 PM
Same problem in rails 3 with IE if having an action that can return the data in .xls format.
-
Santiago Pastorino February 2nd, 2011 @ 04:29 PM
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino February 2nd, 2011 @ 04:29 PM
- State changed from open to stale
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>