lib/httpx/io/tcp.rb in httpx-0.9.0 vs lib/httpx/io/tcp.rb in httpx-0.10.0

- old
+ new

@@ -5,16 +5,12 @@ module HTTPX class TCP include Loggable - attr_reader :ip, :port + attr_reader :ip, :port, :addresses, :state - attr_reader :addresses - - attr_reader :state - alias_method :host, :ip def initialize(origin, addresses, options) @state = :idle @hostname = origin.host @@ -84,20 +80,22 @@ if RUBY_VERSION < "2.3" # :nocov: def read(size, buffer) @io.read_nonblock(size, buffer) + log { "READ: #{buffer.bytesize} bytes..." } buffer.bytesize rescue ::IO::WaitReadable buffer.clear 0 rescue EOFError nil end def write(buffer) siz = @io.write_nonblock(buffer) + log { "WRITE: #{siz} bytes..." } buffer.shift!(siz) siz rescue ::IO::WaitWritable 0 rescue EOFError @@ -111,16 +109,19 @@ buffer.clear return 0 end return if ret.nil? + log { "READ: #{buffer.bytesize} bytes..." } buffer.bytesize end def write(buffer) siz = @io.write_nonblock(buffer, exception: false) return 0 if siz == :wait_writable return if siz.nil? + + log { "WRITE: #{siz} bytes..." } buffer.shift!(siz) siz end end