Loading lib/httpx/connection.rb +12 −2 Original line number Diff line number Diff line Loading @@ -47,8 +47,8 @@ module HTTPX def initialize(uri, options) @current_session = @current_selector = @max_concurrent_requests = @parser = @sibling = @coalesced_connection = @altsvc_connection = @family = @io = @ssl_session = @timeout = @connected_at = @response_received_at = nil @ping_timer = @family = @io = @ssl_session = @timeout = @connected_at = @response_received_at = nil @exhausted = @cloned = @main_sibling = false Loading Loading @@ -956,10 +956,20 @@ module HTTPX return if parser.waiting_for_ping? parser.ping ping_timeout = @options.timeout[:ping_timeout] @ping_timer = @current_selector.after(ping_timeout) do error = PingTimeoutError.new(ping_timeout, "Timed out after #{ping_timeout} seconds") on_error(error) end call end def pong @ping_timer.cancel @ping_timer = nil @response_received_at = Utils.now @no_more_requests_counter = 0 send_pending Loading lib/httpx/connection/http1.rb +4 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,10 @@ module HTTPX end def reset if @ping_timer @ping_timer.cancel @ping_timer = nil end @max_requests = @options.max_requests || MAX_REQUESTS @parser.reset! @handshake_completed = false Loading lib/httpx/errors.rb +4 −1 Original line number Diff line number Diff line Loading @@ -72,9 +72,12 @@ module HTTPX # Error raised when there was a timeout while resolving a domain to an IP. class ResolveTimeoutError < TimeoutError; end # Error raise when there was a timeout waiting for readiness of the socket the request is related to. # Error raised when there was a timeout waiting for readiness of the socket the request is related to. class OperationTimeoutError < TimeoutError; end # Error raised when a connection liveness probe (aka ping) times out. class PingTimeoutError < TimeoutError; end # Error raised when there was an error while resolving a domain to an IP. class ResolveError < Error; end Loading lib/httpx/options.rb +4 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ module HTTPX WINDOW_SIZE = 1 << 14 # 16K MAX_BODY_THRESHOLD_SIZE = (1 << 10) * 112 # 112K KEEP_ALIVE_TIMEOUT = 20 PING_TIMEOUT = 2 SETTINGS_TIMEOUT = 10 CLOSE_HANDSHAKE_TIMEOUT = 10 CONNECT_TIMEOUT = READ_TIMEOUT = WRITE_TIMEOUT = 60 Loading Loading @@ -79,7 +80,7 @@ module HTTPX # :compress_request_body :: whether to auto-decompress response body (defaults to <tt>true</tt>) # :timeout :: hash of timeout configurations (supports <tt>:connect_timeout</tt>, <tt>:settings_timeout</tt>, # <tt>:operation_timeout</tt>, <tt>:keep_alive_timeout</tt>, <tt>:read_timeout</tt>, <tt>:write_timeout</tt>, # <tt>:request_timeout</tt> and <tt>:total_request_timeout</tt> # <tt>:request_timeout</tt>, <tt>:total_request_timeout</tt> and <tt>:ping_timeout</tt>, # :headers :: hash of HTTP headers (ex: <tt>{ "x-custom-foo" => "bar" }</tt>) # :max_response_body_size :: maximum size (in bytes) that the response body can consume (no threshold by default), after which an # error is raised. Loading Loading @@ -568,6 +569,7 @@ module HTTPX close_handshake_timeout: CLOSE_HANDSHAKE_TIMEOUT, operation_timeout: OPERATION_TIMEOUT, keep_alive_timeout: KEEP_ALIVE_TIMEOUT, ping_timeout: PING_TIMEOUT, read_timeout: READ_TIMEOUT, write_timeout: WRITE_TIMEOUT, request_timeout: REQUEST_TIMEOUT, Loading sig/connection.rbs +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ module HTTPX @sibling: instance? @main_sibling: bool @no_more_requests_counter: Integer @ping_timer: Timers::Timer? def addresses: () -> Array[Resolver::Entry]? Loading Loading
lib/httpx/connection.rb +12 −2 Original line number Diff line number Diff line Loading @@ -47,8 +47,8 @@ module HTTPX def initialize(uri, options) @current_session = @current_selector = @max_concurrent_requests = @parser = @sibling = @coalesced_connection = @altsvc_connection = @family = @io = @ssl_session = @timeout = @connected_at = @response_received_at = nil @ping_timer = @family = @io = @ssl_session = @timeout = @connected_at = @response_received_at = nil @exhausted = @cloned = @main_sibling = false Loading Loading @@ -956,10 +956,20 @@ module HTTPX return if parser.waiting_for_ping? parser.ping ping_timeout = @options.timeout[:ping_timeout] @ping_timer = @current_selector.after(ping_timeout) do error = PingTimeoutError.new(ping_timeout, "Timed out after #{ping_timeout} seconds") on_error(error) end call end def pong @ping_timer.cancel @ping_timer = nil @response_received_at = Utils.now @no_more_requests_counter = 0 send_pending Loading
lib/httpx/connection/http1.rb +4 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,10 @@ module HTTPX end def reset if @ping_timer @ping_timer.cancel @ping_timer = nil end @max_requests = @options.max_requests || MAX_REQUESTS @parser.reset! @handshake_completed = false Loading
lib/httpx/errors.rb +4 −1 Original line number Diff line number Diff line Loading @@ -72,9 +72,12 @@ module HTTPX # Error raised when there was a timeout while resolving a domain to an IP. class ResolveTimeoutError < TimeoutError; end # Error raise when there was a timeout waiting for readiness of the socket the request is related to. # Error raised when there was a timeout waiting for readiness of the socket the request is related to. class OperationTimeoutError < TimeoutError; end # Error raised when a connection liveness probe (aka ping) times out. class PingTimeoutError < TimeoutError; end # Error raised when there was an error while resolving a domain to an IP. class ResolveError < Error; end Loading
lib/httpx/options.rb +4 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ module HTTPX WINDOW_SIZE = 1 << 14 # 16K MAX_BODY_THRESHOLD_SIZE = (1 << 10) * 112 # 112K KEEP_ALIVE_TIMEOUT = 20 PING_TIMEOUT = 2 SETTINGS_TIMEOUT = 10 CLOSE_HANDSHAKE_TIMEOUT = 10 CONNECT_TIMEOUT = READ_TIMEOUT = WRITE_TIMEOUT = 60 Loading Loading @@ -79,7 +80,7 @@ module HTTPX # :compress_request_body :: whether to auto-decompress response body (defaults to <tt>true</tt>) # :timeout :: hash of timeout configurations (supports <tt>:connect_timeout</tt>, <tt>:settings_timeout</tt>, # <tt>:operation_timeout</tt>, <tt>:keep_alive_timeout</tt>, <tt>:read_timeout</tt>, <tt>:write_timeout</tt>, # <tt>:request_timeout</tt> and <tt>:total_request_timeout</tt> # <tt>:request_timeout</tt>, <tt>:total_request_timeout</tt> and <tt>:ping_timeout</tt>, # :headers :: hash of HTTP headers (ex: <tt>{ "x-custom-foo" => "bar" }</tt>) # :max_response_body_size :: maximum size (in bytes) that the response body can consume (no threshold by default), after which an # error is raised. Loading Loading @@ -568,6 +569,7 @@ module HTTPX close_handshake_timeout: CLOSE_HANDSHAKE_TIMEOUT, operation_timeout: OPERATION_TIMEOUT, keep_alive_timeout: KEEP_ALIVE_TIMEOUT, ping_timeout: PING_TIMEOUT, read_timeout: READ_TIMEOUT, write_timeout: WRITE_TIMEOUT, request_timeout: REQUEST_TIMEOUT, Loading
sig/connection.rbs +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ module HTTPX @sibling: instance? @main_sibling: bool @no_more_requests_counter: Integer @ping_timer: Timers::Timer? def addresses: () -> Array[Resolver::Entry]? Loading