Skip to content

Commit

Permalink
[DOC] Enhanced RDoc for request headers (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
BurdetteLamar authored Feb 14, 2023
1 parent ed16384 commit b4eb8a7
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 22 deletions.
3 changes: 0 additions & 3 deletions doc/net-http/included_setters.rdoc

This file was deleted.

53 changes: 49 additions & 4 deletions lib/net/http/request.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,55 @@
# frozen_string_literal: false

# This class is the base class for \Net::HTTP request classes;
# it wraps together the request path and the request headers.
#
# This class is the base class for \Net::HTTP request classes.
# The class should not be used directly;
# instead you should use its subclasses.
# instead you should use its subclasses, listed below.
#
# == Creating a Request
#
# An request object may be created with either a URI or a string hostname:
#
# require 'net/http'
# uri = URI('https://jsonplaceholder.typicode.com/')
# req = Net::HTTP::Get.new(uri) # => #<Net::HTTP::Get GET>
# req = Net::HTTP::Get.new(uri.hostname) # => #<Net::HTTP::Get GET>
#
# And with any of the subclasses:
#
# req = Net::HTTP::Head.new(uri) # => #<Net::HTTP::Head HEAD>
# req = Net::HTTP::Post.new(uri) # => #<Net::HTTP::Post POST>
# req = Net::HTTP::Put.new(uri) # => #<Net::HTTP::Put PUT>
# # ...
#
# The new instance is suitable for use as the argument to Net::HTTP#request.
#
# == Request Headers
#
# A new request object has these header fields by default:
#
# req.to_hash
# # =>
# {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
# "accept"=>["*/*"],
# "user-agent"=>["Ruby"],
# "host"=>["jsonplaceholder.typicode.com"]}
#
# See:
#
# - {Request header Accept-Encoding}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Accept-Encoding]
# and {Compression and Decompression}[rdoc-ref:Net::HTTP@Compression+and+Decompression].
# - {Request header Accept}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#accept-request-header].
# - {Request header User-Agent}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#user-agent-request-header].
# - {Request header Host}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#host-request-header].
#
# You can add headers or override default headers:
#
# # res = Net::HTTP::Get.new(uri, {'foo' => '0', 'bar' => '1'})
#
# This class (and therefore its subclasses) also includes (indirectly)
# module Net::HTTPHeader, which gives access to its
# {methods for setting headers}[rdoc-ref:Net::HTTPHeader@Setters].
#
# == Request Subclasses
#
# Subclasses for HTTP requests:
#
Expand Down
30 changes: 15 additions & 15 deletions lib/net/http/requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
Expand Down Expand Up @@ -45,7 +45,7 @@ class Net::HTTP::Get < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
Expand Down Expand Up @@ -79,7 +79,7 @@ class Net::HTTP::Head < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
Expand Down Expand Up @@ -114,7 +114,7 @@ class Net::HTTP::Post < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
Expand Down Expand Up @@ -142,7 +142,7 @@ class Net::HTTP::Put < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
Expand Down Expand Up @@ -173,7 +173,7 @@ class Net::HTTP::Delete < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
Expand Down Expand Up @@ -204,7 +204,7 @@ class Net::HTTP::Options < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
Expand Down Expand Up @@ -238,7 +238,7 @@ class Net::HTTP::Trace < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
Expand Down Expand Up @@ -273,7 +273,7 @@ class Net::HTTP::Patch < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
Expand All @@ -296,7 +296,7 @@ class Net::HTTP::Propfind < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
Expand All @@ -319,7 +319,7 @@ class Net::HTTP::Proppatch < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
Expand All @@ -342,7 +342,7 @@ class Net::HTTP::Mkcol < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
Expand All @@ -365,7 +365,7 @@ class Net::HTTP::Copy < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
Expand All @@ -388,7 +388,7 @@ class Net::HTTP::Move < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
Expand All @@ -411,7 +411,7 @@ class Net::HTTP::Lock < Net::HTTPRequest
# http.request(req)
# end
#
# :include: doc/net-http/included_setters.rdoc
# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
Expand Down

0 comments on commit b4eb8a7

Please sign in to comment.