Class: Pigeon::Http::Response
- Inherits:
-
Object
- Object
- Pigeon::Http::Response
- Defined in:
- lib/pigeon/http.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #body ⇒ Object
- #code ⇒ Object
- #headers ⇒ Object
-
#initialize(response, uri) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
Constructor Details
#initialize(response, uri) ⇒ Response
Returns a new instance of Response.
160 161 162 163 |
# File 'lib/pigeon/http.rb', line 160 def initialize response, uri @response = response @uri = uri end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
158 159 160 |
# File 'lib/pigeon/http.rb', line 158 def response @response end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
158 159 160 |
# File 'lib/pigeon/http.rb', line 158 def uri @uri end |
Instance Method Details
#body ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/pigeon/http.rb', line 173 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
165 166 167 |
# File 'lib/pigeon/http.rb', line 165 def code response.code.to_i end |
#headers ⇒ Object
169 170 171 |
# File 'lib/pigeon/http.rb', line 169 def headers @headers ||= Hash[response.each_header.entries] end |
#inspect ⇒ Object
189 190 191 |
# File 'lib/pigeon/http.rb', line 189 def inspect "#<#{self.class} @code=#{code} @uri=#{uri}>" end |