Skip to content

Commit 55e17fa

Browse files
mamehsbt
authored andcommitted
Revert "lib/net/http/response.rb: support raw deflate correctly"
This reverts commit 5105240b1e851410020b3b3f1a2bead7ffdd4291. 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]
1 parent bce16bd commit 55e17fa

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

lib/net/http/response.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def inflater # :nodoc:
264264
when 'deflate', 'gzip', 'x-gzip' then
265265
self.delete 'content-encoding'
266266

267-
inflate_body_io = Inflater.new(@socket, v.downcase == "deflate")
267+
inflate_body_io = Inflater.new(@socket)
268268

269269
begin
270270
yield inflate_body_io
@@ -358,10 +358,10 @@ class Inflater # :nodoc:
358358
##
359359
# Creates a new Inflater wrapping +socket+
360360

361-
def initialize(socket, raw_deflate)
361+
def initialize socket
362362
@socket = socket
363363
# zlib with automatic gzip detection
364-
@inflate = Zlib::Inflate.new(raw_deflate ? -Zlib::MAX_WBITS : 32 + Zlib::MAX_WBITS)
364+
@inflate = Zlib::Inflate.new(32 + Zlib::MAX_WBITS)
365365
end
366366

367367
##

test/net/http/test_httpresponse.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ def test_read_body_content_encoding_deflate
107107
HTTP/1.1 200 OK
108108
Connection: close
109109
Content-Encoding: deflate
110-
Content-Length: 7
110+
Content-Length: 13
111111
112-
\xCBH\xCD\xC9\xC9\a\x00
112+
x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15
113113
EOS
114114

115115
res = Net::HTTPResponse.read_new(io)
@@ -126,7 +126,7 @@ def test_read_body_content_encoding_deflate
126126
assert_equal 'hello', body
127127
else
128128
assert_equal 'deflate', res['content-encoding']
129-
assert_equal "\xCBH\xCD\xC9\xC9\a\x00", body
129+
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
130130
end
131131
end
132132

@@ -135,9 +135,9 @@ def test_read_body_content_encoding_deflate_uppercase
135135
HTTP/1.1 200 OK
136136
Connection: close
137137
Content-Encoding: DEFLATE
138-
Content-Length: 7
138+
Content-Length: 13
139139
140-
\xCBH\xCD\xC9\xC9\a\x00
140+
x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15
141141
EOS
142142

143143
res = Net::HTTPResponse.read_new(io)
@@ -154,7 +154,7 @@ def test_read_body_content_encoding_deflate_uppercase
154154
assert_equal 'hello', body
155155
else
156156
assert_equal 'DEFLATE', res['content-encoding']
157-
assert_equal "\xCBH\xCD\xC9\xC9\a\x00", body
157+
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
158158
end
159159
end
160160

@@ -165,10 +165,10 @@ def test_read_body_content_encoding_deflate_chunked
165165
Content-Encoding: deflate
166166
Transfer-Encoding: chunked
167167
168-
4
169-
\xCBH\xCD\xC9
170-
3
171-
\xC9\a\x00
168+
6
169+
x\x9C\xCBH\xCD\xC9
170+
7
171+
\xC9\a\x00\x06,\x02\x15
172172
0
173173
174174
EOS
@@ -187,7 +187,7 @@ def test_read_body_content_encoding_deflate_chunked
187187
assert_equal 'hello', body
188188
else
189189
assert_equal 'deflate', res['content-encoding']
190-
assert_equal "\xCBH\xCD\xC9\xC9\a\x00", body
190+
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
191191
end
192192
end
193193

@@ -196,9 +196,9 @@ def test_read_body_content_encoding_deflate_disabled
196196
HTTP/1.1 200 OK
197197
Connection: close
198198
Content-Encoding: deflate
199-
Content-Length: 7
199+
Content-Length: 13
200200
201-
\xCBH\xCD\xC9\xC9\a\x00
201+
x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15
202202
EOS
203203

204204
res = Net::HTTPResponse.read_new(io)
@@ -211,7 +211,7 @@ def test_read_body_content_encoding_deflate_disabled
211211
end
212212

213213
assert_equal 'deflate', res['content-encoding'], 'Bug #7831'
214-
assert_equal "\xCBH\xCD\xC9\xC9\a\x00", body, 'Bug #7381'
214+
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body, 'Bug #7381'
215215
end
216216

217217
def test_read_body_content_encoding_deflate_no_length
@@ -220,7 +220,7 @@ def test_read_body_content_encoding_deflate_no_length
220220
Connection: close
221221
Content-Encoding: deflate
222222
223-
\xCBH\xCD\xC9\xC9\a\x00
223+
x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15
224224
EOS
225225

226226
res = Net::HTTPResponse.read_new(io)
@@ -237,7 +237,7 @@ def test_read_body_content_encoding_deflate_no_length
237237
assert_equal 'hello', body
238238
else
239239
assert_equal 'deflate', res['content-encoding']
240-
assert_equal "\xCBH\xCD\xC9\xC9\a\x00\r\n", body
240+
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15\r\n", body
241241
end
242242
end
243243

0 commit comments

Comments
 (0)