From 745d95c7e06c82cdba257f89263ad8a72ab79b85 Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Sat, 7 Mar 2020 22:57:08 +0000 Subject: [PATCH] close http2 connection as soon as it served all possible requests; this will make the persistent plugin account for resources better --- lib/httpx/connection/http1.rb | 2 +- lib/httpx/connection/http2.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/httpx/connection/http1.rb b/lib/httpx/connection/http1.rb index 423ece28..f3066bfc 100644 --- a/lib/httpx/connection/http1.rb +++ b/lib/httpx/connection/http1.rb @@ -47,7 +47,7 @@ module HTTPX end def send(request) - if !@max_requests.positive? + unless @max_requests.positive? @pending << request return end diff --git a/lib/httpx/connection/http2.rb b/lib/httpx/connection/http2.rb index b08ff3c2..9083bef2 100644 --- a/lib/httpx/connection/http2.rb +++ b/lib/httpx/connection/http2.rb @@ -202,6 +202,10 @@ module HTTPX @streams.delete(request) send(@pending.shift) unless @pending.empty? + return unless @streams.empty? && exhausted? + + close + emit(:close) end def on_frame(bytes)