diff options
Diffstat (limited to 'lib/net/http/response.rb')
-rw-r--r-- | lib/net/http/response.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index ecbfd42d2b..9cedbdbbfe 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -431,6 +431,9 @@ class Net::HTTPResponse ensure begin inflate_body_io.finish + if self['content-length'] + self['content-length'] = inflate_body_io.bytes_inflated.to_s + end rescue => err # Ignore #finish's error if there is an exception from yield raise err if success @@ -533,6 +536,14 @@ class Net::HTTPResponse 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+. # # This allows a large response body to be inflated without storing the |