mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
channels are resettable (meaning, they transition to closed right away), which is important for when there is an error (like timeout or network)
This commit is contained in:
parent
8e8240f5fc
commit
ab69d4aa39
@ -112,6 +112,12 @@ module HTTPX
|
||||
end
|
||||
end
|
||||
|
||||
def reset
|
||||
transition(:closing)
|
||||
transition(:closed)
|
||||
emit(:close)
|
||||
end
|
||||
|
||||
def send(request, **args)
|
||||
if @parser && !@write_buffer.full?
|
||||
parser.send(request, **args)
|
||||
@ -139,7 +145,7 @@ module HTTPX
|
||||
end
|
||||
|
||||
def upgrade_parser(protocol)
|
||||
@parser.close if @parser
|
||||
@parser.reset if @parser
|
||||
@parser = build_parser(protocol)
|
||||
end
|
||||
|
||||
|
@ -108,6 +108,7 @@ module HTTPX
|
||||
break if requests.empty?
|
||||
rescue TimeoutError => e
|
||||
responses << ErrorResponse.new(e.message, 0) while requests.shift
|
||||
@connection.reset
|
||||
break
|
||||
end
|
||||
end
|
||||
|
@ -34,6 +34,10 @@ module HTTPX
|
||||
end
|
||||
end
|
||||
|
||||
def reset
|
||||
@channels.each(&:reset)
|
||||
end
|
||||
|
||||
def build_channel(uri, **options)
|
||||
channel = Channel.by(uri, @options.merge(options))
|
||||
register_channel(channel)
|
||||
|
Loading…
x
Reference in New Issue
Block a user