Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11066 (new defect)

Opened 1 year ago

[PATCH] ActiveResource should handle a weird HTTP 204 response from a remote RESTful rails controller

Reported by: ricky_lui Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveResource Version: edge
Severity: normal Keywords:
Cc:

Description

When ActiveResource does a PUT (e.g. update) to a remote RESTful rails controller that returns a

head :ok

or

render :nothing => true, :status => :ok

Everything is good. But if ActiveResource talks to a remote controller that does:

head :no_content #204

The remote controller sends back an http response of a Net::HTTPNoContent, but its Content-Length is "1" !!

I think ActiveResource should handle this weird behaviour of 'net/http' by doing a simple nil check of response.body in load_attributes_from_response(). Examples of ActiveResource seem to encourage the remote controller to return a 204 response, so that makes it more relevant to fix this.

Attachments

handle_a_weird_but_real_net_http_204_response.diff (1.7 kB) - added by ricky_lui on 02/09/08 19:31:38.
attached patch assumes the path of ~/edge_rails/activeresource

Change History

02/09/08 19:31:38 changed by ricky_lui

  • attachment handle_a_weird_but_real_net_http_204_response.diff added.

attached patch assumes the path of ~/edge_rails/activeresource