mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-16 00:01:48 -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
|
def close
|
||||||
@parser.close if @parser
|
@parser.close if @parser
|
||||||
@keep_alive_timer.cancel if @keep_alive_timer
|
@keep_alive_timer.cancel if @keep_alive_timer
|
||||||
transition(:closing)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset
|
def reset
|
||||||
@ -321,8 +320,12 @@ module HTTPX
|
|||||||
parser.on(:origin) do |origin|
|
parser.on(:origin) do |origin|
|
||||||
@origins << origin
|
@origins << origin
|
||||||
end
|
end
|
||||||
parser.on(:close) do
|
parser.on(:close) do |force|
|
||||||
transition(:closing)
|
transition(:closing)
|
||||||
|
if force
|
||||||
|
transition(:closed)
|
||||||
|
emit(:close)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
parser.on(:reset) do
|
parser.on(:reset) do
|
||||||
if parser.empty?
|
if parser.empty?
|
||||||
|
@ -30,7 +30,7 @@ module HTTPX
|
|||||||
|
|
||||||
def close
|
def close
|
||||||
reset
|
reset
|
||||||
emit(:close)
|
emit(:close, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def exhausted?
|
def exhausted?
|
||||||
|
@ -36,6 +36,7 @@ module HTTPX
|
|||||||
|
|
||||||
def close
|
def close
|
||||||
@connection.goaway unless @connection.state == :closed
|
@connection.goaway unless @connection.state == :closed
|
||||||
|
emit(:close)
|
||||||
end
|
end
|
||||||
|
|
||||||
def empty?
|
def empty?
|
||||||
@ -219,7 +220,6 @@ module HTTPX
|
|||||||
return unless @streams.empty? && exhausted?
|
return unless @streams.empty? && exhausted?
|
||||||
|
|
||||||
close
|
close
|
||||||
emit(:close)
|
|
||||||
emit(:exhausted) unless @pending.empty?
|
emit(:exhausted) unless @pending.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "time"
|
||||||
|
|
||||||
module Requests
|
module Requests
|
||||||
module Get
|
module Get
|
||||||
def test_http_get
|
def test_http_get
|
||||||
|
Loading…
x
Reference in New Issue
Block a user