Skip to content

Commit

Permalink
maintain blocks passed to 'perform' in redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuller committed Mar 12, 2013
1 parent 5e6ea14 commit f8a3e59
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/httparty/request.rb
Expand Up @@ -103,7 +103,7 @@ def perform(&block)
end

handle_deflation
handle_response(chunked_body)
handle_response(chunked_body, &block)
end

private
Expand Down Expand Up @@ -172,14 +172,14 @@ def query_string(uri)
query_string_parts.size > 0 ? query_string_parts.join('&') : nil
end

def handle_response(body)
def handle_response(body, &block)
if response_redirects?
options[:limit] -= 1
self.path = last_response['location']
self.redirect = true
self.http_method = Net::HTTP::Get unless options[:maintain_method_across_redirects]
capture_cookies(last_response)
perform
perform(&block)
else
body = body || last_response.body
Response.new(self, last_response, lambda { parse_response(body) }, :body => body)
Expand Down

0 comments on commit f8a3e59

Please sign in to comment.