Sha256: 86e07271d67fd898117cd295be441c73f77df511018ee35f1ac09ded3b2d826e
Contents?: true
Size: 1.24 KB
Versions: 10
Compression:
Stored size: 1.24 KB
Contents
module WWW class Mechanize class Chain class BodyDecodingHandler include WWW::Handler def handle(ctx, options) body = options[:response_body] response = options[:response] options[:response_body] = if encoding = response['Content-Encoding'] case encoding.downcase when 'gzip' Mechanize.log.debug('gunzip body') if Mechanize.log if response['Content-Length'].to_i > 0 || body.length > 0 begin Zlib::GzipReader.new(body).read rescue Zlib::BufError, Zlib::GzipFile::Error if Mechanize.log Mechanize.log.error('Caught a Zlib::BufError') end body.rewind body.read(10) Zlib::Inflate.new(-Zlib::MAX_WBITS).inflate(body.read) end else '' end when 'x-gzip' body.read else raise 'Unsupported content encoding' end else body.read end super end end end end end
Version data entries
10 entries across 10 versions & 2 rubygems