# File lib/mechanize/http/agent.rb, line 374
  def content_encoding_gunzip body_io
    log.debug('gzip response') if log

    zio = Zlib::GzipReader.new body_io
    out_io = auto_io 'mechanize-gunzip', 16384, zio
    zio.finish

    return out_io
  rescue Zlib::Error
    log.error('unable to gunzip response, trying raw inflate') if log

    body_io.rewind
    body_io.read 10

    begin
      return inflate body_io, -Zlib::MAX_WBITS
    rescue Zlib::Error => e
      log.error("unable to gunzip response: #{e}") if log
      raise
    end
  ensure
    zio.close if zio and not zio.closed?
    body_io.close unless body_io.closed?
  end