lib/httpx/plugins/compression.rb in httpx-0.7.0 vs lib/httpx/plugins/compression.rb in httpx-0.8.0

- old
+ new

@@ -35,10 +35,12 @@ def initialize(*) super return if @body.nil? @headers.get("content-encoding").each do |encoding| + next if encoding == "identity" + @body = Encoder.new(@body, Compression.registry(encoding).encoder) end @headers["content-length"] = @body.bytesize unless chunked? end end @@ -52,17 +54,19 @@ super return unless @headers.key?("content-encoding") @_decoders = @headers.get("content-encoding").map do |encoding| + next if encoding == "identity" + decoder = Compression.registry(encoding).decoder # do not uncompress if there is no decoder available. In fact, we can't reliably # continue decompressing beyond that, so ignore. break unless decoder @encodings << encoding decoder - end + end.compact # remove encodings that we are able to decode @headers["content-encoding"] = @headers.get("content-encoding") - @encodings @_compressed_length = if @headers.key?("content-length")