Class: Net::HTTPResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/xero_gateway/http_encoding_helper.rb

Instance Method Summary collapse

Instance Method Details

#plain_bodyObject

Return the uncompressed content



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/xero_gateway/http_encoding_helper.rb', line 30

def plain_body
  encoding=self['content-encoding']
  content=nil
  if encoding then
    case encoding
      when 'gzip'
        i=Zlib::GzipReader.new(StringIO.new(self.body))
        content=i.read
      when 'deflate'
        i=Zlib::Inflate.new
        content=i.inflate(self.body)
      else
        raise "Unknown encoding - #{encoding}"
    end
  else
    content=self.body
  end
  return content
end