Class: HTTPX::Plugins::Brotli::Inflater

Inherits:
Object
  • Object
show all
Defined in:
lib/httpx/plugins/brotli.rb

Instance Method Summary collapse

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

Raises:



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