Class: HTTPX::Plugins::Brotli::Inflater
- Inherits:
-
Object
- Object
- HTTPX::Plugins::Brotli::Inflater
- Defined in:
- lib/httpx/plugins/brotli.rb
Instance Method Summary collapse
- #call(chunk) ⇒ Object
-
#initialize(bytesize) ⇒ Inflater
constructor
A new instance of Inflater.
Constructor Details
#initialize(bytesize) ⇒ Inflater
22 23 24 25 |
# File 'lib/httpx/plugins/brotli.rb', line 22 def initialize(bytesize) @inflater = ::Brotli::Decompressor.new @bytesize = bytesize end |
Instance Method Details
#call(chunk) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/httpx/plugins/brotli.rb', line 27 def call(chunk) buffer = @inflater.process(chunk) @bytesize -= chunk.bytesize raise Error, "Unexpected end of compressed stream" if @bytesize <= 0 && !@inflater.finished? buffer end |