allow parser to close connection by passing a special flag

this works for http/1, where one can close the socket immediately.
This commit is contained in:
HoneyryderChuck 2020-04-05 04:19:53 +01:00
parent 79d71dcc92
commit 0136200b85
4 changed files with 9 additions and 4 deletions

View File

@ -192,7 +192,6 @@ module HTTPX
def close
@parser.close if @parser
@keep_alive_timer.cancel if @keep_alive_timer
transition(:closing)
end
def reset
@ -321,8 +320,12 @@ module HTTPX
parser.on(:origin) do |origin|
@origins << origin
end
parser.on(:close) do
parser.on(:close) do |force|
transition(:closing)
if force
transition(:closed)
emit(:close)
end
end
parser.on(:reset) do
if parser.empty?

View File

@ -30,7 +30,7 @@ module HTTPX
def close
reset
emit(:close)
emit(:close, true)
end
def exhausted?

View File

@ -36,6 +36,7 @@ module HTTPX
def close
@connection.goaway unless @connection.state == :closed
emit(:close)
end
def empty?
@ -219,7 +220,6 @@ module HTTPX
return unless @streams.empty? && exhausted?
close
emit(:close)
emit(:exhausted) unless @pending.empty?
end

View File

@ -1,5 +1,7 @@
# frozen_string_literal: true
require "time"
module Requests
module Get
def test_http_get