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.

RackResponse 304 output not compatible with XMLHTTPRequest spec

#1636

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:

  1. If the response entity body is "null" terminate these steps and return null.

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

Reported by Brian Johnson · December 26th, 2008 @ 02:28 AM

State: invalid
Milestone: 2.x
Assigned to: josh josh
Importance: none

Activity

  1. Brian Johnson
    Brian Johnson

    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

    December 26th, 2008 @ 11:55 PM

  2. Pratik
    Pratik
    • Assigned user set to josh

    March 8th, 2009 @ 05:30 PM

  3. josh
    josh
    • 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.

    http://rack.lighthouseapp.com/

    March 10th, 2009 @ 03:15 AM