mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Merge branch 'ruby187-chunked-body'
This commit is contained in:
commit
e5b22bd9a7
2 changed files with 11 additions and 9 deletions
|
@ -70,6 +70,7 @@ module HTTParty
|
||||||
def perform(&block)
|
def perform(&block)
|
||||||
validate
|
validate
|
||||||
setup_raw_request
|
setup_raw_request
|
||||||
|
chunked_body = nil
|
||||||
|
|
||||||
self.last_response = http.request(@raw_request) do |http_response|
|
self.last_response = http.request(@raw_request) do |http_response|
|
||||||
if block
|
if block
|
||||||
|
@ -80,12 +81,12 @@ module HTTParty
|
||||||
block.call(fragment)
|
block.call(fragment)
|
||||||
end
|
end
|
||||||
|
|
||||||
http_response.body = chunks.join
|
chunked_body = chunks.join
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
handle_deflation
|
handle_deflation
|
||||||
handle_response
|
handle_response(chunked_body)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -196,7 +197,7 @@ module HTTParty
|
||||||
query_string_parts.size > 0 ? query_string_parts.join('&') : nil
|
query_string_parts.size > 0 ? query_string_parts.join('&') : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_response
|
def handle_response(body)
|
||||||
if response_redirects?
|
if response_redirects?
|
||||||
options[:limit] -= 1
|
options[:limit] -= 1
|
||||||
self.path = last_response['location']
|
self.path = last_response['location']
|
||||||
|
@ -205,7 +206,8 @@ module HTTParty
|
||||||
capture_cookies(last_response)
|
capture_cookies(last_response)
|
||||||
perform
|
perform
|
||||||
else
|
else
|
||||||
Response.new(self, last_response, parse_response(last_response.body))
|
body = body || last_response.body
|
||||||
|
Response.new(self, last_response, parse_response(body), :body => body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,12 @@ module HTTParty
|
||||||
|
|
||||||
attr_reader :request, :response, :parsed_response, :body, :headers
|
attr_reader :request, :response, :parsed_response, :body, :headers
|
||||||
|
|
||||||
def initialize(request, response, parsed_response)
|
def initialize(request, response, parsed_response, options={})
|
||||||
@request = request
|
@request = request
|
||||||
@response = response
|
@response = response
|
||||||
@body = response.body
|
@body = response.body || options[:body]
|
||||||
@parsed_response = parsed_response
|
@parsed_response = parsed_response
|
||||||
@headers = Headers.new(response.to_hash)
|
@headers = Headers.new(response.to_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
def class
|
def class
|
||||||
|
|
Loading…
Add table
Reference in a new issue