Class: Rest::Wrappers::NetHttpPersistentResponseWrapper
- Inherits:
-
BaseResponseWrapper
- Object
- BaseResponseWrapper
- Rest::Wrappers::NetHttpPersistentResponseWrapper
- Defined in:
- lib/rest/wrappers/net_http_persistent_wrapper.rb
Instance Attribute Summary
Attributes inherited from BaseResponseWrapper
Instance Method Summary collapse
- #body ⇒ Object
-
#body_raw ⇒ Object
In case for some reason you want the unencoded body.
- #code ⇒ Object
- #headers_orig ⇒ Object
-
#initialize(response) ⇒ NetHttpPersistentResponseWrapper
constructor
A new instance of NetHttpPersistentResponseWrapper.
Methods inherited from BaseResponseWrapper
Constructor Details
#initialize(response) ⇒ NetHttpPersistentResponseWrapper
Returns a new instance of NetHttpPersistentResponseWrapper.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rest/wrappers/net_http_persistent_wrapper.rb', line 14 def initialize(response) @response = response if response.header['content-encoding'].eql?('gzip') Rest.logger.debug 'GZIPPED' if response.body sio = StringIO.new(response.body) gz = Zlib::GzipReader.new(sio) page = gz.read() @body = page else @body = nil end end end |
Instance Method Details
#body ⇒ Object
36 37 38 |
# File 'lib/rest/wrappers/net_http_persistent_wrapper.rb', line 36 def body @body || @response.body end |
#body_raw ⇒ Object
In case for some reason you want the unencoded body
41 42 43 |
# File 'lib/rest/wrappers/net_http_persistent_wrapper.rb', line 41 def body_raw @response.body end |
#code ⇒ Object
32 33 34 |
# File 'lib/rest/wrappers/net_http_persistent_wrapper.rb', line 32 def code @response.code.to_i end |
#headers_orig ⇒ Object
45 46 47 |
# File 'lib/rest/wrappers/net_http_persistent_wrapper.rb', line 45 def headers_orig @response.to_hash end |