Skip to content

Commit 7b852b1

Browse files
committed
Revert "Update the content-length heading when decoding bodies"
This reverts commit a7cb301. This is causing errors in Ruby's CI, will revert for now and try again after testing a fix with Ruby's CI.
1 parent a7cb301 commit 7b852b1

File tree

2 files changed

+0
-25
lines changed

2 files changed

+0
-25
lines changed

lib/net/http/response.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ def inflater # :nodoc:
263263
case v&.downcase
264264
when 'deflate', 'gzip', 'x-gzip' then
265265
self.delete 'content-encoding'
266-
had_content_length = self.delete 'content-length'
267266

268267
inflate_body_io = Inflater.new(@socket)
269268

@@ -273,9 +272,6 @@ def inflater # :nodoc:
273272
ensure
274273
begin
275274
inflate_body_io.finish
276-
if had_content_length
277-
self['content-length'] = inflate_body_io.bytes_inflated.to_s
278-
end
279275
rescue => err
280276
# Ignore #finish's error if there is an exception from yield
281277
raise err if success
@@ -377,14 +373,6 @@ def finish
377373
@inflate.finish
378374
end
379375

380-
##
381-
# The number of bytes inflated, used to update the Content-Length of
382-
# the response.
383-
384-
def bytes_inflated
385-
@inflate.total_out
386-
end
387-
388376
##
389377
# Returns a Net::ReadAdapter that inflates each read chunk into +dest+.
390378
#

test/net/http/test_httpresponse.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,9 @@ def test_read_body_content_encoding_deflate
127127

128128
if Net::HTTP::HAVE_ZLIB
129129
assert_equal nil, res['content-encoding']
130-
assert_equal '5', res['content-length']
131130
assert_equal 'hello', body
132131
else
133132
assert_equal 'deflate', res['content-encoding']
134-
assert_equal '13', res['content-length']
135133
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
136134
end
137135
end
@@ -157,11 +155,9 @@ def test_read_body_content_encoding_deflate_uppercase
157155

158156
if Net::HTTP::HAVE_ZLIB
159157
assert_equal nil, res['content-encoding']
160-
assert_equal '5', res['content-length']
161158
assert_equal 'hello', body
162159
else
163160
assert_equal 'DEFLATE', res['content-encoding']
164-
assert_equal '13', res['content-length']
165161
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
166162
end
167163
end
@@ -192,11 +188,9 @@ def test_read_body_content_encoding_deflate_chunked
192188

193189
if Net::HTTP::HAVE_ZLIB
194190
assert_equal nil, res['content-encoding']
195-
assert_equal nil, res['content-length']
196191
assert_equal 'hello', body
197192
else
198193
assert_equal 'deflate', res['content-encoding']
199-
assert_equal nil, res['content-length']
200194
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
201195
end
202196
end
@@ -221,7 +215,6 @@ def test_read_body_content_encoding_deflate_disabled
221215
end
222216

223217
assert_equal 'deflate', res['content-encoding'], 'Bug #7831'
224-
assert_equal '13', res['content-length']
225218
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body, 'Bug #7381'
226219
end
227220

@@ -245,11 +238,9 @@ def test_read_body_content_encoding_deflate_no_length
245238

246239
if Net::HTTP::HAVE_ZLIB
247240
assert_equal nil, res['content-encoding']
248-
assert_equal nil, res['content-length']
249241
assert_equal 'hello', body
250242
else
251243
assert_equal 'deflate', res['content-encoding']
252-
assert_equal nil, res['content-length']
253244
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15\r\n", body
254245
end
255246
end
@@ -297,11 +288,9 @@ def test_read_body_content_encoding_deflate_empty_body
297288

298289
if Net::HTTP::HAVE_ZLIB
299290
assert_equal nil, res['content-encoding']
300-
assert_equal '0', res['content-length']
301291
assert_equal '', body
302292
else
303293
assert_equal 'deflate', res['content-encoding']
304-
assert_equal '0', res['content-length']
305294
assert_equal '', body
306295
end
307296
end
@@ -325,11 +314,9 @@ def test_read_body_content_encoding_deflate_empty_body_no_length
325314

326315
if Net::HTTP::HAVE_ZLIB
327316
assert_equal nil, res['content-encoding']
328-
assert_equal nil, res['content-length']
329317
assert_equal '', body
330318
else
331319
assert_equal 'deflate', res['content-encoding']
332-
assert_equal nil, res['content-length']
333320
assert_equal '', body
334321
end
335322
end

0 commit comments

Comments
 (0)