Class: HTTP::Client::Response
- Inherits:
-
Object
- Object
- HTTP::Client::Response
- Defined in:
- lib/http/client.rb
Overview
Request
Instance Attribute Summary collapse
-
#last_effective_uri ⇒ Object
readonly
Returns the value of attribute last_effective_uri.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #body ⇒ Object
- #code ⇒ Object
- #headers ⇒ Object
-
#initialize(response, last_effective_uri) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
Constructor Details
#initialize(response, last_effective_uri) ⇒ Response
Returns a new instance of Response.
273 274 275 276 |
# File 'lib/http/client.rb', line 273 def initialize response, last_effective_uri @response = response @last_effective_uri = last_effective_uri end |
Instance Attribute Details
#last_effective_uri ⇒ Object (readonly)
Returns the value of attribute last_effective_uri.
271 272 273 |
# File 'lib/http/client.rb', line 271 def last_effective_uri @last_effective_uri end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
271 272 273 |
# File 'lib/http/client.rb', line 271 def response @response end |
Instance Method Details
#body ⇒ Object
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/http/client.rb', line 286 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 ⇒ Object
278 279 280 |
# File 'lib/http/client.rb', line 278 def code response.code.to_i end |
#headers ⇒ Object
282 283 284 |
# File 'lib/http/client.rb', line 282 def headers @headers ||= Hash[response.each_header.entries] end |
#inspect ⇒ Object
302 303 304 |
# File 'lib/http/client.rb', line 302 def inspect "#<#{self.class} @code=#{code} @last_effective_uri=#{last_effective_uri}>" end |