Skip to content

Commit ed16384

Browse files
authored
Merge pull request #119 from BurdetteLamar/http_doc
[DOC] Enhanced RDoc for Compression
2 parents 099b662 + cff88ac commit ed16384

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

lib/net/http.rb

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,13 +428,31 @@ class HTTPHeaderSyntaxError < StandardError; end
428428
# http = Net::HTTP.new('example.com', nil, 'my.proxy', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000')
429429
# http.proxy_address # => nil
430430
#
431-
# == Compression
431+
# == Compression and Decompression
432432
#
433-
# \Net::HTTP automatically adds Accept-Encoding for compression of response
434-
# bodies and automatically decompresses gzip and deflate responses unless a
435-
# Range header was sent.
433+
# \Net::HTTP does not compress the body of a request before sending.
436434
#
437-
# Compression can be disabled through the Accept-Encoding: identity header.
435+
# By default, \Net::HTTP adds header <tt>'Accept-Encoding'</tt>
436+
# to a new {request object}[rdoc-ref:Net::HTTPRequest]:
437+
#
438+
# Net::HTTP::Get.new(uri)['Accept-Encoding']
439+
# # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
440+
#
441+
# This requests the server to zip-encode the response body if there is one;
442+
# the server is not required to do so.
443+
#
444+
# \Net::HTTP does not automatically decompress a response body
445+
# if the response has header <tt>'Content-Range'</tt>.
446+
#
447+
# Otherwise decompression (or not) depends on the value of header
448+
# {Content-Encoding}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-encoding-response-header]:
449+
#
450+
# - <tt>'deflate'</tt>, <tt>'gzip'</tt>, or <tt>'x-gzip'</tt>:
451+
# decompresses the body and deletes the header.
452+
# - <tt>'none'</tt> or <tt>'identity'</tt>:
453+
# does not decompress the body, but deletes the header.
454+
# - Any other value:
455+
# leaves the body and header unchanged.
438456
#
439457
class HTTP < Protocol
440458

0 commit comments

Comments
 (0)