Module: HTTPX::Plugins::Compression::ResponseBodyMethods
- Defined in:
- lib/httpx/plugins/compression.rb
Instance Method Summary collapse
Instance Method Details
#close ⇒ Object
48 49 50 51 |
# File 'lib/httpx/plugins/compression.rb', line 48 def close super @_decoders.each(&:close) end |
#initialize ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/httpx/plugins/compression.rb', line 30 def initialize(*) super @_decoders = @headers.get("content-encoding").map do |encoding| Compression.registry(encoding).decoder end @_compressed_length = if @headers.key?("content-length") @headers["content-length"].to_i else Float::INFINITY end end |
#write(chunk) ⇒ Object
42 43 44 45 46 |
# File 'lib/httpx/plugins/compression.rb', line 42 def write(chunk) @_compressed_length -= chunk.bytesize chunk = decompress(chunk) super(chunk) end |