read_chunked(dest, chunk_data_io)
private
read_chunked reads from
+@socket+ for chunk-size, chunk-extension, CRLF, etc. and
chunk_data_io for chunk-data which may be deflate or gzip encoded.
See RFC 2616 section 3.6.1 for definitions
Show source
def read_chunked(dest, chunk_data_io)
len = nil
total = 0
while true
line = @socket.readline
hexlen = line.slice(/[0-9a-fA-F]+/) or
raise Net::HTTPBadResponse, "wrong chunk size line: #{line}"
len = hexlen.hex
break if len == 0
begin
chunk_data_io.read len, dest
ensure
total += len
@socket.read 2
end
end
until @socket.readline.empty?
end
end