ActiveResource::Base#create data is not loaded if the transfer-encoding is chunked #2079

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants
@jkrall

jkrall commented Jul 15, 2011

Fixing bug in ActiveResource::Base#create where returned data is not loaded if the transfer-encoding is chunked. Includes tests & all ActiveResource tests pass.

Commit 154081f created this bug, with the goal of fixing 204 responses. There were no tests with this patch, so I added new tests to cover this & my own issue. Refactored the load_attributes_from_response method to make the logic around when to load attributes more obvious.

Fixing bug in AR::Base#create where returned data is not loaded if th…
…e transfer-encoding is chunked. Includes tests & all ActiveResource tests pass.
@sporkd

This comment has been minimized.

Show comment Hide comment
@sporkd

sporkd Jul 16, 2011

Thank you! Thank you! I just ran into this sam issue today as well. Hard to debug too because it was only breaking against our production API.

sporkd commented Jul 16, 2011

Thank you! Thank you! I just ran into this sam issue today as well. Hard to debug too because it was only breaking against our production API.

+ has_body = !response.body.nil? && response.body.strip.size > 0
+ is_chunked = response["Transfer-Encoding"] == "chunked"
+
+ if has_body && (has_content_length || is_chunked)

This comment has been minimized.

Show comment Hide comment
@jreidinger

jreidinger Sep 27, 2011

Contributor

is_chunked is not neccessary as net response object has method chunked?
so it should look like
if has_body && (has_content_length || response.chunked?)

@jreidinger

jreidinger Sep 27, 2011

Contributor

is_chunked is not neccessary as net response object has method chunked?
so it should look like
if has_body && (has_content_length || response.chunked?)

@jreidinger

This comment has been minimized.

Show comment Hide comment
@jreidinger

jreidinger Sep 27, 2011

Contributor

Please include this fix as it is really annoying that one rails server which produce chunked output cannot serve to another one which read it.

Contributor

jreidinger commented Sep 27, 2011

Please include this fix as it is really annoying that one rails server which produce chunked output cannot serve to another one which read it.

@carlosantoniodasilva

This comment has been minimized.

Show comment Hide comment
@carlosantoniodasilva

carlosantoniodasilva Apr 28, 2012

Member

ActiveResource has been moved out from Rails to its own repo. If this is still considered an issue, please reopen the pull request on ARes repo with updated code. I'm closing it here, thanks!

ActiveResource has been moved out from Rails to its own repo. If this is still considered an issue, please reopen the pull request on ARes repo with updated code. I'm closing it here, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment