Class: Protocol::HTTP::Body::Inflate
- Defined in:
- lib/protocol/http/body/inflate.rb
Constant Summary
Constants inherited from ZStream
ZStream::DEFAULT_LEVEL, ZStream::DEFLATE, ZStream::ENCODINGS, ZStream::GZIP
Instance Attribute Summary
Attributes inherited from ZStream
Attributes inherited from Wrapper
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from ZStream
#close, encoding_name, #initialize, #inspect, #length, #ratio
Methods inherited from Wrapper
#close, #empty?, #finish, #initialize, #inspect, #length
Methods inherited from Readable
#call, #close, #each, #empty?, #finish, #join, #length
Constructor Details
This class inherits a constructor from Protocol::HTTP::Body::ZStream
Class Method Details
.for(body, encoding = GZIP) ⇒ Object
29 30 31 |
# File 'lib/protocol/http/body/inflate.rb', line 29 def self.for(body, encoding = GZIP) self.new(body, Zlib::Inflate.new(encoding)) end |
Instance Method Details
#read ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/protocol/http/body/inflate.rb', line 33 def read return if @stream.finished? # The stream might have been closed while waiting for the chunk to come in. if chunk = super @input_length += chunk.bytesize # It's possible this triggers the stream to finish. chunk = @stream.inflate(chunk) @output_length += chunk.bytesize elsif !@stream.closed? chunk = @stream.finish @output_length += chunk.bytesize end if chunk.empty? and @stream.finished? return nil end return chunk end |