class HTTPX::Transcoder::Deflate::Deflater

  1. lib/httpx/transcoder/deflate.rb
Superclass: Deflater

Methods

Public Instance

  1. deflate

Public Instance methods

deflate(chunk)
[show source]
   # File lib/httpx/transcoder/deflate.rb
10 def deflate(chunk)
11   @deflater ||= Zlib::Deflate.new
12 
13   unless chunk.nil?
14     chunk = @deflater.deflate(chunk)
15 
16     # deflate call may return nil, while still
17     # retaining the last chunk in the deflater.
18     return chunk unless chunk.empty?
19   end
20 
21   return if @deflater.closed?
22 
23   last = @deflater.finish
24   @deflater.close
25 
26   last unless last.empty?
27 end