class HTTP::Client::Response

Attributes

last_effective_uri[R]
response[R]

Public Class Methods

new(response, last_effective_uri) click to toggle source
# File lib/http/client.rb, line 287
def initialize response, last_effective_uri
  @response           = response
  @last_effective_uri = last_effective_uri
end

Public Instance Methods

body() click to toggle source
# File lib/http/client.rb, line 300
def body
  case headers['content-encoding'].to_s.downcase
    when 'gzip'
      gz = Zlib::GzipReader.new(StringIO.new(response.body))
      begin
        gz.read
      ensure
        gz.close
      end
    when 'deflate'
      Zlib.inflate(response.body)
    else
      response.body
  end
end
code() click to toggle source
# File lib/http/client.rb, line 292
def code
  response.code.to_i
end
headers() click to toggle source
# File lib/http/client.rb, line 296
def headers
  @headers ||= Hash[response.each_header.entries]
end
inspect() click to toggle source
# File lib/http/client.rb, line 316
def inspect
  "#<#{self.class} @code=#{code} @last_effective_uri=#{last_effective_uri}>"
end