mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Revert "lib/net/http/response.rb: support raw deflate correctly"
This reverts commit 5105240b1e
.
In RFC 2616:
```
deflate
The "zlib" format defined in RFC 1950 [31] in combination with
the "deflate" compression mechanism described in RFC 1951 [29].
```
So "Content-Encoding: deflate" means zlib format, not raw deflate.
[Bug #11268]
This commit is contained in:
parent
5105240b1e
commit
251f5d8226
2 changed files with 19 additions and 19 deletions
|
@ -264,7 +264,7 @@ class Net::HTTPResponse
|
||||||
when 'deflate', 'gzip', 'x-gzip' then
|
when 'deflate', 'gzip', 'x-gzip' then
|
||||||
self.delete 'content-encoding'
|
self.delete 'content-encoding'
|
||||||
|
|
||||||
inflate_body_io = Inflater.new(@socket, v.downcase == "deflate")
|
inflate_body_io = Inflater.new(@socket)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
yield inflate_body_io
|
yield inflate_body_io
|
||||||
|
@ -358,10 +358,10 @@ class Net::HTTPResponse
|
||||||
##
|
##
|
||||||
# Creates a new Inflater wrapping +socket+
|
# Creates a new Inflater wrapping +socket+
|
||||||
|
|
||||||
def initialize(socket, raw_deflate)
|
def initialize socket
|
||||||
@socket = socket
|
@socket = socket
|
||||||
# zlib with automatic gzip detection
|
# zlib with automatic gzip detection
|
||||||
@inflate = Zlib::Inflate.new(raw_deflate ? -Zlib::MAX_WBITS : 32 + Zlib::MAX_WBITS)
|
@inflate = Zlib::Inflate.new(32 + Zlib::MAX_WBITS)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -107,9 +107,9 @@ EOS
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Connection: close
|
Connection: close
|
||||||
Content-Encoding: deflate
|
Content-Encoding: deflate
|
||||||
Content-Length: 7
|
Content-Length: 13
|
||||||
|
|
||||||
\xCBH\xCD\xC9\xC9\a\x00
|
x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
res = Net::HTTPResponse.read_new(io)
|
res = Net::HTTPResponse.read_new(io)
|
||||||
|
@ -126,7 +126,7 @@ EOS
|
||||||
assert_equal 'hello', body
|
assert_equal 'hello', body
|
||||||
else
|
else
|
||||||
assert_equal 'deflate', res['content-encoding']
|
assert_equal 'deflate', res['content-encoding']
|
||||||
assert_equal "\xCBH\xCD\xC9\xC9\a\x00", body
|
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -135,9 +135,9 @@ EOS
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Connection: close
|
Connection: close
|
||||||
Content-Encoding: DEFLATE
|
Content-Encoding: DEFLATE
|
||||||
Content-Length: 7
|
Content-Length: 13
|
||||||
|
|
||||||
\xCBH\xCD\xC9\xC9\a\x00
|
x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
res = Net::HTTPResponse.read_new(io)
|
res = Net::HTTPResponse.read_new(io)
|
||||||
|
@ -154,7 +154,7 @@ EOS
|
||||||
assert_equal 'hello', body
|
assert_equal 'hello', body
|
||||||
else
|
else
|
||||||
assert_equal 'DEFLATE', res['content-encoding']
|
assert_equal 'DEFLATE', res['content-encoding']
|
||||||
assert_equal "\xCBH\xCD\xC9\xC9\a\x00", body
|
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -165,10 +165,10 @@ Connection: close
|
||||||
Content-Encoding: deflate
|
Content-Encoding: deflate
|
||||||
Transfer-Encoding: chunked
|
Transfer-Encoding: chunked
|
||||||
|
|
||||||
4
|
6
|
||||||
\xCBH\xCD\xC9
|
x\x9C\xCBH\xCD\xC9
|
||||||
3
|
7
|
||||||
\xC9\a\x00
|
\xC9\a\x00\x06,\x02\x15
|
||||||
0
|
0
|
||||||
|
|
||||||
EOS
|
EOS
|
||||||
|
@ -187,7 +187,7 @@ EOS
|
||||||
assert_equal 'hello', body
|
assert_equal 'hello', body
|
||||||
else
|
else
|
||||||
assert_equal 'deflate', res['content-encoding']
|
assert_equal 'deflate', res['content-encoding']
|
||||||
assert_equal "\xCBH\xCD\xC9\xC9\a\x00", body
|
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -196,9 +196,9 @@ EOS
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Connection: close
|
Connection: close
|
||||||
Content-Encoding: deflate
|
Content-Encoding: deflate
|
||||||
Content-Length: 7
|
Content-Length: 13
|
||||||
|
|
||||||
\xCBH\xCD\xC9\xC9\a\x00
|
x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
res = Net::HTTPResponse.read_new(io)
|
res = Net::HTTPResponse.read_new(io)
|
||||||
|
@ -211,7 +211,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'deflate', res['content-encoding'], 'Bug #7831'
|
assert_equal 'deflate', res['content-encoding'], 'Bug #7831'
|
||||||
assert_equal "\xCBH\xCD\xC9\xC9\a\x00", body, 'Bug #7381'
|
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body, 'Bug #7381'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_read_body_content_encoding_deflate_no_length
|
def test_read_body_content_encoding_deflate_no_length
|
||||||
|
@ -220,7 +220,7 @@ HTTP/1.1 200 OK
|
||||||
Connection: close
|
Connection: close
|
||||||
Content-Encoding: deflate
|
Content-Encoding: deflate
|
||||||
|
|
||||||
\xCBH\xCD\xC9\xC9\a\x00
|
x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
res = Net::HTTPResponse.read_new(io)
|
res = Net::HTTPResponse.read_new(io)
|
||||||
|
@ -237,7 +237,7 @@ EOS
|
||||||
assert_equal 'hello', body
|
assert_equal 'hello', body
|
||||||
else
|
else
|
||||||
assert_equal 'deflate', res['content-encoding']
|
assert_equal 'deflate', res['content-encoding']
|
||||||
assert_equal "\xCBH\xCD\xC9\xC9\a\x00\r\n", body
|
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15\r\n", body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue