From 5c338e32f97836c1da3deae365efa2349ca186db Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 3 Sep 2024 21:30:48 +1200 Subject: [PATCH] Copy protocol if successful. --- lib/async/http/protocol/http2/response.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/async/http/protocol/http2/response.rb b/lib/async/http/protocol/http2/response.rb index 13e0c41..0415d98 100644 --- a/lib/async/http/protocol/http2/response.rb +++ b/lib/async/http/protocol/http2/response.rb @@ -54,6 +54,11 @@ def receive_initial_headers(headers, end_stream) @response.status = status @headers = ::Protocol::HTTP::Headers.new + # If the protocol request was successful, ensure the response protocol matches: + if status == 200 and protocol = @response.request.protocol + @response.protocol = Array(protocol).first + end + headers.each do |key, value| # It's guaranteed that this should be the first header: if key == CONTENT_LENGTH