Class: Net::HTTPGenericRequest::Chunker

Inherits:
Object
  • Object
show all
Defined in:
lib/net/http/generic_request.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(sock) ⇒ Chunker

Returns a new instance of Chunker.



163
164
165
166
# File 'lib/net/http/generic_request.rb', line 163

def initialize(sock)
  @sock = sock
  @prev = nil
end

Instance Method Details

#finishObject



176
177
178
# File 'lib/net/http/generic_request.rb', line 176

def finish
  @sock.write("0\r\n\r\n")
end

#write(buf) ⇒ Object



168
169
170
171
172
173
174
# File 'lib/net/http/generic_request.rb', line 168

def write(buf)
  # avoid memcpy() of buf, buf can huge and eat memory bandwidth
  @sock.write("#{buf.bytesize.to_s(16)}\r\n")
  rv = @sock.write(buf)
  @sock.write("\r\n")
  rv
end