mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
do not throw stuff, parser on close must trigger transition
This commit is contained in:
parent
7db7fad7a9
commit
0763242cce
@ -154,7 +154,10 @@ module HTTPX
|
||||
def dread(wsize = @window_size)
|
||||
loop do
|
||||
siz = @io.read(wsize, @read_buffer)
|
||||
throw(:close, self) unless siz
|
||||
unless siz
|
||||
emit(:close)
|
||||
return
|
||||
end
|
||||
return if siz.zero?
|
||||
log { "READ: #{siz} bytes..." }
|
||||
parser << @read_buffer.to_s
|
||||
@ -165,7 +168,10 @@ module HTTPX
|
||||
loop do
|
||||
return if @write_buffer.empty?
|
||||
siz = @io.write(@write_buffer)
|
||||
throw(:close, self) unless siz
|
||||
unless siz
|
||||
emit(:close)
|
||||
return
|
||||
end
|
||||
log { "WRITE: #{siz} bytes..." }
|
||||
return if siz.zero?
|
||||
end
|
||||
@ -190,11 +196,8 @@ module HTTPX
|
||||
parser.on(:promise) do |*args|
|
||||
emit(:promise, *args)
|
||||
end
|
||||
# parser.inherit_callbacks(self)
|
||||
parser.on(:complete) { throw(:close, self) }
|
||||
parser.on(:close) do
|
||||
transition(:closed)
|
||||
emit(:close)
|
||||
transition(:closing)
|
||||
end
|
||||
parser
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ module HTTPX
|
||||
return if @io.closed?
|
||||
@parser = ConnectProxyParser.new(@write_buffer, @options.merge(max_concurrent_requests: 1))
|
||||
@parser.once(:response, &method(:on_connect))
|
||||
@parser.on(:complete) { throw(:close, self) }
|
||||
@parser.on(:close) { transition(:closing) }
|
||||
proxy_connect
|
||||
return if @state == :open
|
||||
when :open
|
||||
|
Loading…
x
Reference in New Issue
Block a user