module HTTPX::Plugins::Compression::Deflate::Encoder

  1. lib/httpx/plugins/compression/deflate.rb

Methods

Public Instance

  1. deflate

Public Instance methods

deflate (raw, buffer, chunk_size:)
[show source]
   # File lib/httpx/plugins/compression/deflate.rb
19 def deflate(raw, buffer, chunk_size:)
20   deflater = Zlib::Deflate.new(Zlib::BEST_COMPRESSION,
21                                Zlib::MAX_WBITS,
22                                Zlib::MAX_MEM_LEVEL,
23                                Zlib::HUFFMAN_ONLY)
24   while (chunk = raw.read(chunk_size))
25     compressed = deflater.deflate(chunk)
26     buffer << compressed
27     yield compressed if block_given?
28   end
29   last = deflater.finish
30   buffer << last
31   yield last if block_given?
32 ensure
33   deflater.close
34 end