mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
added support for multiple header frame received callback calls, by merging them (trailer header case)
This commit is contained in:
parent
82dc700059
commit
351276dcb5
@ -215,6 +215,11 @@ module HTTPX
|
||||
######
|
||||
|
||||
def on_stream_headers(stream, request, h)
|
||||
if request.response && request.response.version == "2.0"
|
||||
on_stream_trailers(stream, request, h)
|
||||
return
|
||||
end
|
||||
|
||||
log(color: :yellow) do
|
||||
h.map { |k, v| "#{stream.id}: <- HEADER: #{k}: #{v}" }.join("\n")
|
||||
end
|
||||
@ -227,6 +232,13 @@ module HTTPX
|
||||
handle(request, stream) if request.expects?
|
||||
end
|
||||
|
||||
def on_stream_trailers(stream, request, h)
|
||||
log(color: :yellow) do
|
||||
h.map { |k, v| "#{stream.id}: <- HEADER: #{k}: #{v}" }.join("\n")
|
||||
end
|
||||
request.response.merge_headers(h)
|
||||
end
|
||||
|
||||
def on_stream_data(stream, request, data)
|
||||
log(level: 1, color: :green) { "#{stream.id}: <- DATA: #{data.bytesize} bytes..." }
|
||||
log(level: 2, color: :green) { "#{stream.id}: <- #{data.inspect}" }
|
||||
|
@ -112,7 +112,7 @@ module HTTPX
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
to_hash == Headers.new(other).to_hash
|
||||
other == to_hash
|
||||
end
|
||||
|
||||
# the headers store in Hash format
|
||||
|
@ -57,6 +57,8 @@ module HTTPX
|
||||
|
||||
def on_stream_headers: (HTTP2Next::Stream stream, Request request, Array[[String, String]] headers) -> void
|
||||
|
||||
def on_stream_trailers: (HTTP2Next::Stream stream, Request request, Array[[String, String]] headers) -> void
|
||||
|
||||
def on_stream_data: (HTTP2Next::Stream stream, Request request, string data) -> void
|
||||
|
||||
def on_stream_close: (HTTP2Next::Stream stream, Request request, Symbol? error) -> void
|
||||
|
Loading…
x
Reference in New Issue
Block a user