Hi, just curious.. but why do you need to set the content-length header on the 204 response? according to the HTTP docs, a 204 literally means "no content to send". Perhaps I just misunderstand your requirements? Cheers, Taryn
On Jul 2, 11:48 pm, Mike <mike.ab...@gmail.com> wrote: > https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5... > > I just added this ticket. I'm writing a Sinatra API to be consumed by > Rails and I've run into an issue where the ActiveResource > documentation specifies that on update you should return an HTTP 204 > status with no body. The problem is that Rack doesn't allow you to > set the Content-Length header of HTTP 204 responses. > > The workaround seems to be to return a 200 response with a zero length > Content-Length header and body, but that's not what the docs say. > > The fix is simple and laid out in the ticket, but here it is. > > def load_attributes_from_response(response) > if !response['Conent-Length'].blank? && response['Content-Length'] ! > = "0" && response.body.strip.size > 0 > load(self.class.format.decode(response.body)) > end > end > > This brings up an issue with the HttpMock class included with > ActiveRecord. It defaults to specifying a Content-Type header of 0 > for all requests that don't have a body. Assuming Rack has the HTTP > rules correct (204 shouldn't have that header), then the HttpMock > class is also broken. > > I've just started cloning the repository to create a patch, but I'm > not sure how I should update the tests. Any pointers would be great. > Otherwise if someone wants to throw in the fix for me... > > Thanks. > > Mike -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-c...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.