allow parsers to define a connection timeout, and channge it via callback

This commit is contained in:
HoneyryderChuck 2021-05-30 00:55:30 +01:00
parent b569cc9984
commit 5cfb494d50
9 changed files with 27 additions and 1 deletions

View File

@ -434,6 +434,9 @@ module HTTPX
transition(:open)
end
end
parser.on(:current_timeout) do
@current_timeout = @timeout = parser.timeout
end
parser.on(:timeout) do |tout|
@timeout = tout
end
@ -464,7 +467,7 @@ module HTTPX
send_pending
@timeout = @current_timeout = @options.timeout[:operation_timeout]
@timeout = @current_timeout = parser.timeout
emit(:open)
when :closing
return unless @state == :open

View File

@ -24,6 +24,10 @@ module HTTPX
@handshake_completed = false
end
def timeout
@options.timeout[:operation_timeout]
end
def interests
# this means we're processing incoming response already
return :r if @request

View File

@ -34,6 +34,10 @@ module HTTPX
init_connection
end
def timeout
@options.timeout[:settings_timeout]
end
def interests
# waiting for WINDOW_UPDATE frames
return :r if @buffer.full?
@ -312,6 +316,7 @@ module HTTPX
def on_settings(*)
@handshake_completed = true
emit(:current_timeout)
if @max_requests.zero?
@max_requests = @connection.remote_settings[:settings_max_concurrent_streams]

View File

@ -85,6 +85,10 @@ module HTTPX
@options = Options.new(options)
end
def timeout
@options.timeout[:operation_timeout]
end
def close; end
def consume(*); end

View File

@ -133,6 +133,10 @@ module HTTPX
@options = Options.new(options)
end
def timeout
@options.timeout[:operation_timeout]
end
def close; end
def consume(*); end

View File

@ -42,6 +42,8 @@ module HTTPX
def ping: () -> void
def timeout: () -> Integer
private
def initialize: (Buffer, options) -> untyped

View File

@ -35,6 +35,8 @@ module HTTPX
alias reset init_connection
def timeout: () -> Integer
private
def initialize: (Buffer, options) -> untyped

View File

@ -14,6 +14,7 @@ module HTTPX
class SocksParser
include Callbacks
def timeout: () -> Integer
def close: () -> void
def consume: (*untyped) -> void
def empty: () -> bool

View File

@ -15,6 +15,7 @@ module HTTPX
class SocksParser
include Callbacks
def timeout: () -> Integer
def close: () -> void
def consume: (*untyped) -> void
def empty: () -> bool