Class: Celluloid::Http::BodyDecoder
- Inherits:
-
Object
- Object
- Celluloid::Http::BodyDecoder
- Defined in:
- lib/celluloid-http/body_decoder.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Class Method Summary collapse
Instance Method Summary collapse
- #decode ⇒ Object
- #gunzip(body) ⇒ Object
-
#initialize(headers, raw_body) ⇒ BodyDecoder
constructor
A new instance of BodyDecoder.
- #zip? ⇒ Boolean
Constructor Details
#initialize(headers, raw_body) ⇒ BodyDecoder
Returns a new instance of BodyDecoder.
14 15 16 |
# File 'lib/celluloid-http/body_decoder.rb', line 14 def initialize(headers, raw_body) @headers, @body = headers, raw_body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
13 14 15 |
# File 'lib/celluloid-http/body_decoder.rb', line 13 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
13 14 15 |
# File 'lib/celluloid-http/body_decoder.rb', line 13 def headers @headers end |
Class Method Details
.decode(headers, raw_body) ⇒ Object
7 8 9 |
# File 'lib/celluloid-http/body_decoder.rb', line 7 def decode(headers, raw_body) new(headers, raw_body).decode.body end |
Instance Method Details
#decode ⇒ Object
18 19 20 21 |
# File 'lib/celluloid-http/body_decoder.rb', line 18 def decode @body = gunzip(@body) if zip? self end |
#gunzip(body) ⇒ Object
23 24 25 |
# File 'lib/celluloid-http/body_decoder.rb', line 23 def gunzip(body) Zlib::GzipReader.new(StringIO.new(body)).read end |
#zip? ⇒ Boolean
27 28 29 |
# File 'lib/celluloid-http/body_decoder.rb', line 27 def zip? @headers['Content-Encoding'] == 'gzip' end |