Skip to content

Instantly share code, notes, and snippets.

@semanticart
Created March 16, 2009 13:51
Show Gist options
  • Select an option

  • Save semanticart/79884 to your computer and use it in GitHub Desktop.

Select an option

Save semanticart/79884 to your computer and use it in GitHub Desktop.
def self.decode_content(c)
if c.header_str.match(/Content-Encoding: gzip/)
begin
gz = Zlib::GzipReader.new(StringIO.new(c.body_str))
xml = gz.read
gz.close
rescue Zlib::GzipFile::Error
xml = c.body_str
end
elsif c.header_str.match(/Content-Encoding: deflate/)
xml = Zlib::Deflate.inflate(c.body_str)
else
xml = c.body_str
end
xml
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment