Module: HTTPX::Plugins::Compression::ResponseBodyMethods
- Defined in:
- lib/httpx/plugins/compression.rb
Instance Method Summary collapse
Instance Method Details
#close ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/httpx/plugins/compression.rb', line 62 def close super return unless defined?(@_decoders) @_decoders.each(&:close) end |
#initialize ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/httpx/plugins/compression.rb', line 39 def initialize(*) super return unless @headers.key?("content-encoding") @_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
54 55 56 57 58 59 60 |
# File 'lib/httpx/plugins/compression.rb', line 54 def write(chunk) return super unless defined?(@_compressed_length) @_compressed_length -= chunk.bytesize chunk = decompress(chunk) super(chunk) end |