class Gem::Net::HTTPResponse::Inflater
:nodoc:
def bytes_inflated
def bytes_inflated @inflate.total_out end
def finish
def finish return if @inflate.total_in == 0 @inflate.finish end
def inflate_adapter(dest)
def inflate_adapter(dest) if dest.respond_to?(:set_encoding) dest.set_encoding(Encoding::ASCII_8BIT) elsif dest.respond_to?(:force_encoding) dest.force_encoding(Encoding::ASCII_8BIT) end block = proc do |compressed_chunk| @inflate.inflate(compressed_chunk) do |chunk| compressed_chunk.clear dest << chunk end end Gem::Net::ReadAdapter.new(block) end
def initialize socket
def initialize socket @socket = socket # zlib with automatic gzip detection @inflate = Zlib::Inflate.new(32 + Zlib::MAX_WBITS) end
def read clen, dest, ignore_eof = false
def read clen, dest, ignore_eof = false temp_dest = inflate_adapter(dest) @socket.read clen, temp_dest, ignore_eof end
def read_all dest
def read_all dest temp_dest = inflate_adapter(dest) @socket.read_all temp_dest end