lib/httpx/connection.rb in httpx-0.9.0 vs lib/httpx/connection.rb in httpx-0.10.0
- old
+ new
@@ -49,11 +49,11 @@
attr_writer :timers
def initialize(type, uri, options)
@type = type
@origins = [uri.origin]
- @origin = URI(uri.origin)
+ @origin = Utils.uri(uri.origin)
@options = Options.new(options)
@window_size = @options.window_size
@read_buffer = Buffer.new(BUFFER_SIZE)
@write_buffer = Buffer.new(BUFFER_SIZE)
@pending = []
@@ -140,21 +140,19 @@
true
end
end
end
- def purge_pending
+ def purge_pending(&block)
pendings = []
if @parser
@inflight -= @parser.pending.size
pendings << @parser.pending
end
pendings << @pending
pendings.each do |pending|
- pending.reject! do |request|
- yield request
- end
+ pending.reject!(&block)
end
end
# checks if this is connection is an alternative service of
# +uri+
@@ -291,12 +289,10 @@
if siz.zero?
read_drained = @read_buffer.empty?
break
end
- log { "READ: #{siz} bytes..." }
-
parser << @read_buffer.to_s
break if @state == :closing || @state == :closed
# for HTTP/2, we just want to write goaway frame
@@ -315,11 +311,10 @@
ex = EOFError.new("descriptor closed")
ex.set_backtrace(caller)
on_error(ex)
return
end
- log { "WRITE: #{siz} bytes..." }
if siz.zero?
write_drained = !@write_buffer.empty?
break
end
@@ -458,10 +453,9 @@
reset
emit(:unreachable)
throw(:jump_tick)
rescue Errno::ECONNREFUSED,
Errno::EADDRNOTAVAIL,
- Errno::EHOSTUNREACH,
OpenSSL::SSL::SSLError => e
# connect errors, exit gracefully
handle_error(e)
@state = :closed
emit(:close)