diff --git a/doc/release_notes/0_8_0.md b/doc/release_notes/0_8_0.md index 159b73e7..5fd2181f 100644 --- a/doc/release_notes/0_8_0.md +++ b/doc/release_notes/0_8_0.md @@ -20,6 +20,7 @@ * fixed `compression` plugin not handling `content-encoding: identity` payloads; * do not overwrite user-defined `max_requests`on HTTP2 connection handshake; * `retries` plugin: connection was blocking when a request with body was retried; +* `alt-svc: clear` response header was causing the process to hang; ## Tests diff --git a/lib/httpx/connection.rb b/lib/httpx/connection.rb index 443faed0..af786b68 100644 --- a/lib/httpx/connection.rb +++ b/lib/httpx/connection.rb @@ -281,13 +281,13 @@ module HTTPX return end - log { "READ: #{siz} bytes..." } - if siz.zero? read_drained = @read_buffer.empty? break end + log { "READ: #{siz} bytes..." } + parser << @read_buffer.to_s break if @state == :closing || @state == :closed diff --git a/lib/httpx/connection/http2.rb b/lib/httpx/connection/http2.rb index 1757ffdc..456ce378 100644 --- a/lib/httpx/connection/http2.rb +++ b/lib/httpx/connection/http2.rb @@ -36,7 +36,9 @@ module HTTPX return :w if @connection.state == :closed - return :r unless (@connection.state == :connected && @handshake_completed) + unless (@connection.state == :connected && @handshake_completed) + return @buffer.empty? ? :r : :rw + end return :w unless @pending.empty? diff --git a/lib/httpx/headers.rb b/lib/httpx/headers.rb index 7a87f6a2..437733d8 100644 --- a/lib/httpx/headers.rb +++ b/lib/httpx/headers.rb @@ -67,7 +67,7 @@ module HTTPX # def [](field) a = @headers[downcased(field)] || return - a.join(",") + a.join(", ") end # sets +value+ (if not nil) as single value for the +field+ header. diff --git a/lib/httpx/pool.rb b/lib/httpx/pool.rb index fcecfa30..1d823bee 100644 --- a/lib/httpx/pool.rb +++ b/lib/httpx/pool.rb @@ -37,6 +37,9 @@ module HTTPX @timers.fire end + rescue Interrupt + @connections.each(&:reset) + raise rescue StandardError => e @connections.each do |connection| connection.emit(:error, e) diff --git a/test/headers_test.rb b/test/headers_test.rb index d4a7ae18..53e48c8a 100644 --- a/test/headers_test.rb +++ b/test/headers_test.rb @@ -25,7 +25,7 @@ class HeadersTest < Minitest::Test def test_headers_add h1 = Headers.new("accept" => "text/html") h1.add("accept", "application/xhtml+xml") - assert h1["accept"] == "text/html,application/xhtml+xml", "unexpected header value" + assert h1["accept"] == "text/html, application/xhtml+xml", "unexpected header value" assert h1.get("accept") == %w[text/html application/xhtml+xml], "unexpected header value" end