[ruby/net-http] Revert "Update the content-length heading when decoding bodies"
This reverts commit https://github.com/ruby/net-http/commit/a7cb30124cf1. This is causing errors in Ruby's CI, will revert for now and try again after testing a fix with Ruby's CI. https://github.com/ruby/net-http/commit/7b852b1feb
This commit is contained in:
parent
7be4d900f0
commit
7648bae4c8
@ -263,7 +263,6 @@ class Net::HTTPResponse
|
|||||||
case v&.downcase
|
case v&.downcase
|
||||||
when 'deflate', 'gzip', 'x-gzip' then
|
when 'deflate', 'gzip', 'x-gzip' then
|
||||||
self.delete 'content-encoding'
|
self.delete 'content-encoding'
|
||||||
had_content_length = self.delete 'content-length'
|
|
||||||
|
|
||||||
inflate_body_io = Inflater.new(@socket)
|
inflate_body_io = Inflater.new(@socket)
|
||||||
|
|
||||||
@ -273,9 +272,6 @@ class Net::HTTPResponse
|
|||||||
ensure
|
ensure
|
||||||
begin
|
begin
|
||||||
inflate_body_io.finish
|
inflate_body_io.finish
|
||||||
if had_content_length
|
|
||||||
self['content-length'] = inflate_body_io.bytes_inflated.to_s
|
|
||||||
end
|
|
||||||
rescue => err
|
rescue => err
|
||||||
# Ignore #finish's error if there is an exception from yield
|
# Ignore #finish's error if there is an exception from yield
|
||||||
raise err if success
|
raise err if success
|
||||||
@ -377,14 +373,6 @@ class Net::HTTPResponse
|
|||||||
@inflate.finish
|
@inflate.finish
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
|
||||||
# The number of bytes inflated, used to update the Content-Length of
|
|
||||||
# the response.
|
|
||||||
|
|
||||||
def bytes_inflated
|
|
||||||
@inflate.total_out
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Returns a Net::ReadAdapter that inflates each read chunk into +dest+.
|
# Returns a Net::ReadAdapter that inflates each read chunk into +dest+.
|
||||||
#
|
#
|
||||||
|
@ -127,11 +127,9 @@ EOS
|
|||||||
|
|
||||||
if Net::HTTP::HAVE_ZLIB
|
if Net::HTTP::HAVE_ZLIB
|
||||||
assert_equal nil, res['content-encoding']
|
assert_equal nil, res['content-encoding']
|
||||||
assert_equal '5', res['content-length']
|
|
||||||
assert_equal 'hello', body
|
assert_equal 'hello', body
|
||||||
else
|
else
|
||||||
assert_equal 'deflate', res['content-encoding']
|
assert_equal 'deflate', res['content-encoding']
|
||||||
assert_equal '13', res['content-length']
|
|
||||||
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
|
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -157,11 +155,9 @@ EOS
|
|||||||
|
|
||||||
if Net::HTTP::HAVE_ZLIB
|
if Net::HTTP::HAVE_ZLIB
|
||||||
assert_equal nil, res['content-encoding']
|
assert_equal nil, res['content-encoding']
|
||||||
assert_equal '5', res['content-length']
|
|
||||||
assert_equal 'hello', body
|
assert_equal 'hello', body
|
||||||
else
|
else
|
||||||
assert_equal 'DEFLATE', res['content-encoding']
|
assert_equal 'DEFLATE', res['content-encoding']
|
||||||
assert_equal '13', res['content-length']
|
|
||||||
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
|
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -192,11 +188,9 @@ EOS
|
|||||||
|
|
||||||
if Net::HTTP::HAVE_ZLIB
|
if Net::HTTP::HAVE_ZLIB
|
||||||
assert_equal nil, res['content-encoding']
|
assert_equal nil, res['content-encoding']
|
||||||
assert_equal nil, res['content-length']
|
|
||||||
assert_equal 'hello', body
|
assert_equal 'hello', body
|
||||||
else
|
else
|
||||||
assert_equal 'deflate', res['content-encoding']
|
assert_equal 'deflate', res['content-encoding']
|
||||||
assert_equal nil, res['content-length']
|
|
||||||
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
|
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -221,7 +215,6 @@ EOS
|
|||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'deflate', res['content-encoding'], 'Bug #7831'
|
assert_equal 'deflate', res['content-encoding'], 'Bug #7831'
|
||||||
assert_equal '13', res['content-length']
|
|
||||||
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body, 'Bug #7381'
|
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body, 'Bug #7381'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -245,11 +238,9 @@ EOS
|
|||||||
|
|
||||||
if Net::HTTP::HAVE_ZLIB
|
if Net::HTTP::HAVE_ZLIB
|
||||||
assert_equal nil, res['content-encoding']
|
assert_equal nil, res['content-encoding']
|
||||||
assert_equal nil, res['content-length']
|
|
||||||
assert_equal 'hello', body
|
assert_equal 'hello', body
|
||||||
else
|
else
|
||||||
assert_equal 'deflate', res['content-encoding']
|
assert_equal 'deflate', res['content-encoding']
|
||||||
assert_equal nil, res['content-length']
|
|
||||||
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15\r\n", body
|
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15\r\n", body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -297,11 +288,9 @@ EOS
|
|||||||
|
|
||||||
if Net::HTTP::HAVE_ZLIB
|
if Net::HTTP::HAVE_ZLIB
|
||||||
assert_equal nil, res['content-encoding']
|
assert_equal nil, res['content-encoding']
|
||||||
assert_equal '0', res['content-length']
|
|
||||||
assert_equal '', body
|
assert_equal '', body
|
||||||
else
|
else
|
||||||
assert_equal 'deflate', res['content-encoding']
|
assert_equal 'deflate', res['content-encoding']
|
||||||
assert_equal '0', res['content-length']
|
|
||||||
assert_equal '', body
|
assert_equal '', body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -325,11 +314,9 @@ EOS
|
|||||||
|
|
||||||
if Net::HTTP::HAVE_ZLIB
|
if Net::HTTP::HAVE_ZLIB
|
||||||
assert_equal nil, res['content-encoding']
|
assert_equal nil, res['content-encoding']
|
||||||
assert_equal nil, res['content-length']
|
|
||||||
assert_equal '', body
|
assert_equal '', body
|
||||||
else
|
else
|
||||||
assert_equal 'deflate', res['content-encoding']
|
assert_equal 'deflate', res['content-encoding']
|
||||||
assert_equal nil, res['content-length']
|
|
||||||
assert_equal '', body
|
assert_equal '', body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user