mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
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:
parent
79d71dcc92
commit
0136200b85
@ -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?
|
||||
|
@ -30,7 +30,7 @@ module HTTPX
|
||||
|
||||
def close
|
||||
reset
|
||||
emit(:close)
|
||||
emit(:close, true)
|
||||
end
|
||||
|
||||
def exhausted?
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "time"
|
||||
|
||||
module Requests
|
||||
module Get
|
||||
def test_http_get
|
||||
|
Loading…
x
Reference in New Issue
Block a user