mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
jruby fix: http_parser (still) calls the header callback twice for chunked bodies, work around that
This commit is contained in:
parent
9673825673
commit
8293350d26
@ -65,12 +65,17 @@ module HTTPX
|
||||
end
|
||||
|
||||
def on_headers_complete(h)
|
||||
# Wait for fix: https://github.com/tmm1/http_parser.rb/issues/52
|
||||
# callback is called 2 times when chunked
|
||||
request = @requests.last
|
||||
return if request.response
|
||||
|
||||
log { "headers received" }
|
||||
headers = @options.headers_class.new(h)
|
||||
response = @options.response_class.new(@requests.last, @parser.status_code, headers, @options)
|
||||
log { "#{response.status} HTTP/#{@parser.http_version.join(".")}" }
|
||||
log { response.headers.each.map { |f, v| "-> #{f}: #{v}" }.join("\n") }
|
||||
|
||||
request = @requests.last
|
||||
request.response = response
|
||||
# parser can't say if it's parsing GET or HEAD,
|
||||
# call the completeness callback manually
|
||||
|
Loading…
x
Reference in New Issue
Block a user