Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[Bug #8182] XMLRPC request fails with "Wrong size. Was 31564, should be 1501" #308

Closed
wants to merge 1 commit into from

2 participants

@dmacvicar
  • lib/net/http/response.rb: transparently deflates the response body,
    removes the "content-encoding" response header, but does not adjust
    the "content-length" header accordingly.
    So, pass the context to the Inflater so that we count the
    uncompressed data for every chunk inflated, and then on finish we
    set the right Content-Length.
    [Bug #8182]

  • test/net/http/test_httpresponse.rb: enhance testcase to check
    the right Content-Length

@dmacvicar dmacvicar * lib/net/http/response.rb: transparently deflates the response body,
  removes the "content-encoding" response header, but does not adjust
  the "content-length" header accordingly.
  So, pass the context to the Inflater so that we count the
  uncompressed data for every chunk inflated, and then on finish we
  set the right Content-Length.
  [Bug #8182]

* test/net/http/test_httpresponse.rb: enhance testcase to check
  the right Content-Length
7137383
@zzak
Collaborator

Closing this in favor of the ticket on redmine: http://bugs.ruby-lang.org/issues/8182

@zzak zzak closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 16, 2013
  1. @dmacvicar

    * lib/net/http/response.rb: transparently deflates the response body,

    dmacvicar authored
      removes the "content-encoding" response header, but does not adjust
      the "content-length" header accordingly.
      So, pass the context to the Inflater so that we count the
      uncompressed data for every chunk inflated, and then on finish we
      set the right Content-Length.
      [Bug #8182]
    
    * test/net/http/test_httpresponse.rb: enhance testcase to check
      the right Content-Length
This page is out of date. Refresh to see the latest.
View
13 ChangeLog
@@ -1,3 +1,16 @@
+Thu May 16 18:09:03 2013 Duncan Mac-Vicar P. <dmacvicar@suse.de>
+
+ * lib/net/http/response.rb: transparently deflates the response body,
+ removes the "content-encoding" response header, but does not adjust
+ the "content-length" header accordingly.
+ So, pass the context to the Inflater so that we count the
+ uncompressed data for every chunk inflated, and then on finish we
+ set the right Content-Length.
+ [Bug #8182]
+
+ * test/net/http/test_httpresponse.rb: enhance testcase to check
+ the right Content-Length
+
Wed May 15 17:55:49 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (RUBY_PLATFORM): move to config.h as needed by
View
8 lib/net/http/response.rb
@@ -254,7 +254,7 @@ def inflater # :nodoc:
when 'deflate', 'gzip', 'x-gzip' then
self.delete 'content-encoding'
- inflate_body_io = Inflater.new(@socket)
+ inflate_body_io = Inflater.new(@socket, self)
begin
yield inflate_body_io
@@ -344,8 +344,10 @@ class Inflater # :nodoc:
##
# Creates a new Inflater wrapping +socket+
- def initialize socket
+ def initialize(socket, response)
@socket = socket
+ @response = response
+ @deflated_len = 0
# zlib with automatic gzip detection
@inflate = Zlib::Inflate.new(32 + Zlib::MAX_WBITS)
end
@@ -355,6 +357,7 @@ def initialize socket
def finish
@inflate.finish
+ @response['content-length'] = @deflated_len
end
##
@@ -367,6 +370,7 @@ def inflate_adapter(dest)
block = proc do |compressed_chunk|
@inflate.inflate(compressed_chunk) do |chunk|
dest << chunk
+ @deflated_len += chunk.bytesize
end
end
View
2  test/net/http/test_httpresponse.rb
@@ -96,9 +96,11 @@ def test_read_body_content_encoding_deflate
if Net::HTTP::HAVE_ZLIB
assert_equal nil, res['content-encoding']
+ assert_equal '5', res['content-length'], "Bug #8182"
assert_equal 'hello', body
else
assert_equal 'deflate', res['content-encoding']
+ assert_equal '13', res['content-length'], "Bug #8182"
assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body
end
end
Something went wrong with that request. Please try again.