Class: HTTPX::Plugins::Compression::GZIP::Encoder

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

Instance Method Summary collapse

Instance Method Details

#deflate(raw, buffer, chunk_size:) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/httpx/plugins/compression/gzip.rb', line 18

def deflate(raw, buffer, chunk_size:)
  gzip = Zlib::GzipWriter.new(self)

  while (chunk = raw.read(chunk_size))
    gzip.write(chunk)
    gzip.flush
    compressed = compressed_chunk
    buffer << compressed
    yield compressed if block_given?
  end
ensure
  gzip.close
end