diff --git a/lib/httpx/connection/http2.rb b/lib/httpx/connection/http2.rb index 684e5a56..78a85825 100644 --- a/lib/httpx/connection/http2.rb +++ b/lib/httpx/connection/http2.rb @@ -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}" } diff --git a/lib/httpx/headers.rb b/lib/httpx/headers.rb index d280c173..cdb24eda 100644 --- a/lib/httpx/headers.rb +++ b/lib/httpx/headers.rb @@ -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 diff --git a/sig/connection/http2.rbs b/sig/connection/http2.rbs index ee6ba0c9..40e3f42c 100644 --- a/sig/connection/http2.rbs +++ b/sig/connection/http2.rbs @@ -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