Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

maintain blocks passed to 'perform' in redirects #191

merged 3 commits into from Apr 10, 2013


None yet
2 participants

bmuller commented Mar 12, 2013

Blocks passed to requests only get executed on the first HTTP request and don't get executed on future requests caused by a redirect.

For instance:

HTTParty.get("http://google.com") { |chunk| puts "Got a chunk: #{chunk}\n\n" }

will only print out the lines for the 301 response, but will not be run for the following request.


jnunemaker commented Mar 25, 2013

A regression test to confirm that this works is all the pull needs. Without one, I'm sure I'll break it down the road.


bmuller commented Mar 26, 2013

Test added. Let me know if you need anything else.




bmuller commented Mar 27, 2013

This also fixes another issue (fixed in 3f4a2db) where response.body was returning a Net::ReadAdapter. You can see this behavior by running:

response = HTTParty.get("https://www.google.com/") { |chunk| }

The last line returns an empty Net::ReadAdapter rather than a string. This is due to calling read_body on the response if a block is present - and all subsequent calls to body will be Net::ReadAdapters rather than strings.

@jnunemaker jnunemaker added a commit that referenced this pull request Apr 10, 2013

@jnunemaker jnunemaker Merge pull request #191 from moonshinedevco/master
maintain blocks passed to 'perform' in redirects

@jnunemaker jnunemaker merged commit b165661 into jnunemaker:master Apr 10, 2013

1 check passed

default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment