Feature #6494
closedSend Accept-Encoding for all HTTP requests
Added by drbrain (Eric Hodel) over 13 years ago. Updated over 13 years ago.
Description
Files
| net.http.accept_gzip_deflate_by_default.patch (3.31 KB) net.http.accept_gzip_deflate_by_default.patch | drbrain (Eric Hodel), 05/25/2012 08:22 AM | ||
| net.http.accept_gzip_deflate_by_default.2.patch (2.65 KB) net.http.accept_gzip_deflate_by_default.2.patch | drbrain (Eric Hodel), 05/30/2012 08:55 AM | ||
| net.http.accept_gzip_deflate_by_default.3.patch (4.31 KB) net.http.accept_gzip_deflate_by_default.3.patch | drbrain (Eric Hodel), 06/09/2012 07:20 AM | 
        
           Updated by drbrain (Eric Hodel) over 13 years ago
          
          
        
        
          
            Actions
          
          #1
            [ruby-core:45225]
          Updated by drbrain (Eric Hodel) over 13 years ago
          
          
        
        
          
            Actions
          
          #1
            [ruby-core:45225]
        
      
      - File net.http.accept_gzip_deflate_by_default.patch net.http.accept_gzip_deflate_by_default.patch added
Oops, forgot patch.
        
           Updated by naruse (Yui NARUSE) over 13 years ago
          
          
        
        
          
            Actions
          
          #2
            [ruby-core:45296]
          Updated by naruse (Yui NARUSE) over 13 years ago
          
          
        
        
          
            Actions
          
          #2
            [ruby-core:45296]
        
      
      This change breaks code which calls initialize with initheader=nil.
- def initialize(m, reqbody, resbody, path, initheader = nil)
- def initialize(m, reqbody, resbody, path, initheader = {})
Following
- if @response_has_body and Net::HTTP::HAVE_ZLIB then
- 
unless initheader.keys.any? { |k| k.downcase == "accept-encoding" }
- 
initheader = initheader.merge({
- 
"accept-encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
- 
})
- 
end
- end
should be
- 
if !initheader || !initheader.keys.any? { |k| k.downcase == "accept-encoding" }
- 
initheader = initheader ? initheader.dup : {}
- 
initheader["accept-encoding"] = "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
- 
end
        
           Updated by drbrain (Eric Hodel) over 13 years ago
          
          
        
        
          
            Actions
          
          #3
            [ruby-core:45312]
          Updated by drbrain (Eric Hodel) over 13 years ago
          
          
        
        
          
            Actions
          
          #3
            [ruby-core:45312]
        
      
      - File net.http.accept_gzip_deflate_by_default.2.patch net.http.accept_gzip_deflate_by_default.2.patch added
Why remove the HAVE_ZLIB and @response_has_body checks?
This updated patch incorporates your change to maintain backwards-compatibility but leaves in the HAVE_ZLIB and @response_has_body checks.
        
           Updated by naruse (Yui NARUSE) over 13 years ago
          
          
        
        
          
            Actions
          
          #4
            [ruby-core:45324]
          Updated by naruse (Yui NARUSE) over 13 years ago
          
          
        
        
          
            Actions
          
          #4
            [ruby-core:45324]
        
      
      drbrain (Eric Hodel) wrote:
Why remove the HAVE_ZLIB and @response_has_body checks?
Ah, I wrongly removed it, it is needed.
This updated patch incorporates your change to maintain backwards-compatibility but leaves in the HAVE_ZLIB and @response_has_body checks.
OK, you can commit it, thanks.
        
           Updated by mame (Yusuke Endoh) over 13 years ago
          
          
        
        
          
            Actions
          
          #5
            [ruby-core:45337]
          Updated by mame (Yusuke Endoh) over 13 years ago
          
          
        
        
          
            Actions
          
          #5
            [ruby-core:45337]
        
      
      - Status changed from Open to Assigned
- Assignee set to naruse (Yui NARUSE)
        
           Updated by naruse (Yui NARUSE) over 13 years ago
          
          
        
        
          
            Actions
          
          #6
            [ruby-core:45366]
          Updated by naruse (Yui NARUSE) over 13 years ago
          
          
        
        
          
            Actions
          
          #6
            [ruby-core:45366]
        
      
      - Assignee changed from naruse (Yui NARUSE) to drbrain (Eric Hodel)
        
           Updated by drbrain (Eric Hodel) over 13 years ago
          
          
        
        
          
            Actions
          
          #7
            [ruby-core:45376]
          Updated by drbrain (Eric Hodel) over 13 years ago
          
          
        
        
          
            Actions
          
          #7
            [ruby-core:45376]
        
      
      I will commit this once #6492 is approved and committed.
        
           Updated by drbrain (Eric Hodel) over 13 years ago
          
          
        
        
          
            Actions
          
          #8
            [ruby-core:45523]
          Updated by drbrain (Eric Hodel) over 13 years ago
          
          
        
        
          
            Actions
          
          #8
            [ruby-core:45523]
        
      
      - File net.http.accept_gzip_deflate_by_default.3.patch net.http.accept_gzip_deflate_by_default.3.patch added
Due to feedback from #6492 I have updated this patch to omit Accept-Encoding when Range is supplied in initheader.
I've also added documentation to this patch to describe the new compression behavior.
        
           Updated by drbrain (Eric Hodel) over 13 years ago
          
          
        
        
          
            Actions
          
          #9
          Updated by drbrain (Eric Hodel) over 13 years ago
          
          
        
        
          
            Actions
          
          #9
        
      
      - Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r36473.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- lib/net/http/response.rb:  Automatically inflate gzip and
 deflate-encoded response bodies. [Feature #6942]
- lib/net/http/generic_request.rb:  Automatically accept gzip and
 deflate content-encoding for requests. [Feature #6494]
- lib/net/http/request.rb: Updated documentation for #6494.
- lib/net/http.rb:  Updated documentation for #6492 and #6494, removed
 Content-Encoding handling now present in Net::HTTPResponse.
- test/net/http/test_httpresponse.rb: Tests for #6492
- test/net/http/test_http_request.rb: Tests for #6494
- test/open-uri/test_open-uri.rb (test_content_encoding):  Updated test
 for automatic content-encoding handling.