From cff88acd7089f0a3746c3315f335430e037b8a62 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Thu, 9 Feb 2023 22:52:01 +0000 Subject: [PATCH] Enhanced RDoc for Compression --- lib/net/http.rb | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index 2d284c0c..15fc348b 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -428,13 +428,31 @@ class HTTPHeaderSyntaxError < StandardError; end # http = Net::HTTP.new('example.com', nil, 'my.proxy', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000') # http.proxy_address # => nil # - # == Compression + # == Compression and Decompression # - # \Net::HTTP automatically adds Accept-Encoding for compression of response - # bodies and automatically decompresses gzip and deflate responses unless a - # Range header was sent. + # \Net::HTTP does not compress the body of a request before sending. # - # Compression can be disabled through the Accept-Encoding: identity header. + # By default, \Net::HTTP adds header 'Accept-Encoding' + # to a new {request object}[rdoc-ref:Net::HTTPRequest]: + # + # Net::HTTP::Get.new(uri)['Accept-Encoding'] + # # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" + # + # This requests the server to zip-encode the response body if there is one; + # the server is not required to do so. + # + # \Net::HTTP does not automatically decompress a response body + # if the response has header 'Content-Range'. + # + # Otherwise decompression (or not) depends on the value of header + # {Content-Encoding}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-encoding-response-header]: + # + # - 'deflate', 'gzip', or 'x-gzip': + # decompresses the body and deletes the header. + # - 'none' or 'identity': + # does not decompress the body, but deletes the header. + # - Any other value: + # leaves the body and header unchanged. # class HTTP < Protocol