This project is archived and is in readonly mode.
RackResponse 304 output not compatible with XMLHTTPRequest spec
Reported by Brian Johnson | December 26th, 2008 @ 02:28 AM | in 2.x
This is the relevant section:
The XML response entity body is either a Document representing the response entity body or null. The XML response entity body is the return value of the following algorithm:
-
If the response entity body is "null" terminate these steps and return null.
-
If a Content-Type is present and it does not contain a MIME type (ignoring any parameters) that is text/xml, application/xml or ends in +xml terminate these steps and return null. (Do not terminate these steps if there is no Content-Type header at all.)
The problem is that rack_process.rb deletes the content type and sets the output to [] which returns an empty response body. Because it removes the content-type header, XMLHTTPRequest will interpret the response as text/xml. An empty string is not valid XML and will produce a "no element found" error in Firefox. It seems that the out/to_a method should set the content type to something like text/plain or return a response body of "null" for 304 status responses.
We use AJAX calls to return JSON data to a grid and would like to be able to use etags to keep the load/traffic down on the server.
Comments and changes to this ticket
-
Brian Johnson December 26th, 2008 @ 11:55 PM
Seems to also be a problem with CgiResponse. If I do something like this
render :text => "null", :status => :not_modified, :content_type => 'text/plain'
it still renders with an empty body and no content type
-
Pratik March 8th, 2009 @ 05:30 PM
- Assigned user set to josh
-
josh March 10th, 2009 @ 03:15 AM
- State changed from new to invalid
I think Rack is doing the correct thing, but I'm not entirely sure.
Anyway, this is something that needs to be fixed in Rack, not Rails. Please file a ticket on the Rack lighthouse. Assign the ticket to Ryan Tomayko, the HTTP caching expert.
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>