# File lib/mechanize/chain/body_decoding_handler.rb, line 6 6: def handle(ctx, options) 7: body = options[:response_body] 8: response = options[:response] 9: 10: options[:response_body] = 11: if encoding = response['Content-Encoding'] 12: case encoding.downcase 13: when 'gzip' 14: Mechanize.log.debug('gunzip body') if Mechanize.log 15: if response['Content-Length'].to_i > 0 || body.length > 0 16: begin 17: Zlib::GzipReader.new(body).read 18: rescue Zlib::BufError, Zlib::GzipFile::Error 19: if Mechanize.log 20: Mechanize.log.error('Caught a Zlib::BufError') 21: end 22: body.rewind 23: body.read(10) 24: Zlib::Inflate.new(-Zlib::MAX_WBITS).inflate(body.read) 25: rescue Zlib::DataError 26: if Mechanize.log 27: Mechanize.log.error("Caught a Zlib::DataError, unable to decode page: #{$!.to_s}") 28: end 29: '' 30: end 31: else 32: '' 33: end 34: when 'x-gzip' 35: body.read 36: when '7bit' 37: body.read 38: else 39: raise 'Unsupported content encoding' 40: end 41: else 42: body.read 43: end 44: super 45: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.