summaryrefslogtreecommitdiff
path: root/lib/net/http
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-12-16 23:20:42 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-12-16 23:20:42 +0900
commit5105240b1e851410020b3b3f1a2bead7ffdd4291 (patch)
tree2a51dd29300cc4041503b3260f117e0e81c9a099 /lib/net/http
parentd6fd39030d8b14eef117c1e5e265e0b769a9f4fd (diff)
lib/net/http/response.rb: support raw deflate correctly
Net::HTTP had used `Zlib::Inflate.new(32 + Zlib::MAX_WBITS)` for all content encoding (deflate, zlib, and gzip). But the argument `32 + Zlib::MAX_WBITS` means zlib and gzip decoding with automatic header detection, so (raw) deflate compression had not been supported. This change makes it support raw deflate correctly by passing an argument `-Zlib::MAX_WBITS` (which means raw deflate) to `Zlib::Inflate.new`. All deflate-mode tests are fixed too. [Bug #11268]
Diffstat (limited to 'lib/net/http')
-rw-r--r--lib/net/http/response.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb
index 5a94f95694..7c89876d44 100644
--- a/lib/net/http/response.rb
+++ b/lib/net/http/response.rb
@@ -264,7 +264,7 @@ class Net::HTTPResponse
when 'deflate', 'gzip', 'x-gzip' then
self.delete 'content-encoding'
- inflate_body_io = Inflater.new(@socket)
+ inflate_body_io = Inflater.new(@socket, v.downcase == "deflate")
begin
yield inflate_body_io
@@ -358,10 +358,10 @@ class Net::HTTPResponse
##
# Creates a new Inflater wrapping +socket+
- def initialize socket
+ def initialize(socket, raw_deflate)
@socket = socket
# zlib with automatic gzip detection
- @inflate = Zlib::Inflate.new(32 + Zlib::MAX_WBITS)
+ @inflate = Zlib::Inflate.new(raw_deflate ? -Zlib::MAX_WBITS : 32 + Zlib::MAX_WBITS)
end
##