Class: HTTP::Response::Inflater
- Inherits:
-
Object
- Object
- HTTP::Response::Inflater
- Defined in:
- lib/http/response/inflater.rb,
sig/http.rbs
Overview
Decompresses gzip/deflate response body streams
Instance Attribute Summary collapse
-
#connection ⇒ HTTP::Connection
readonly
The underlying connection.
Instance Method Summary collapse
-
#initialize(connection) ⇒ Inflater
constructor
Create a new Inflater wrapping a connection.
-
#readpartial ⇒ String
Read and inflate a chunk of the response body.
-
#zstream ⇒ Zlib::Inflate
private
Return the zlib inflate stream.
Constructor Details
#initialize(connection) ⇒ Inflater
Create a new Inflater wrapping a connection
26 27 28 |
# File 'lib/http/response/inflater.rb', line 26 def initialize(connection) @connection = connection end |
Instance Attribute Details
#connection ⇒ HTTP::Connection (readonly)
The underlying connection
16 17 18 |
# File 'lib/http/response/inflater.rb', line 16 def connection @connection end |
Instance Method Details
#readpartial ⇒ String
Read and inflate a chunk of the response body
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/http/response/inflater.rb', line 38 def readpartial(*) chunk = @connection.readpartial(*) zstream.inflate(chunk) rescue EOFError unless zstream.closed? zstream.finished? ? zstream.finish : zstream.reset zstream.close end raise end |
#zstream ⇒ Zlib::Inflate
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the zlib inflate stream
55 56 57 |
# File 'lib/http/response/inflater.rb', line 55 def zstream @zstream ||= Zlib::Inflate.new(32 + Zlib::MAX_WBITS) end |