rbs 3.0.0.dev.2 → 3.0.0.dev.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -1
  3. data/.github/workflows/ruby.yml +4 -0
  4. data/Gemfile.lock +11 -11
  5. data/Rakefile +2 -2
  6. data/Steepfile +1 -1
  7. data/core/array.rbs +573 -423
  8. data/core/basic_object.rbs +11 -39
  9. data/core/binding.rbs +1 -1
  10. data/core/builtin.rbs +8 -0
  11. data/core/class.rbs +37 -0
  12. data/core/comparable.rbs +7 -18
  13. data/core/complex.rbs +2 -2
  14. data/core/data.rbs +419 -0
  15. data/core/dir.rbs +52 -104
  16. data/core/encoding.rbs +22 -181
  17. data/core/enumerable.rbs +212 -175
  18. data/core/enumerator/product.rbs +96 -0
  19. data/core/enumerator.rbs +57 -8
  20. data/core/errors.rbs +8 -2
  21. data/core/exception.rbs +41 -0
  22. data/core/fiber.rbs +95 -12
  23. data/core/file.rbs +840 -275
  24. data/core/file_test.rbs +34 -19
  25. data/core/float.rbs +40 -96
  26. data/core/gc.rbs +15 -3
  27. data/core/hash.rbs +113 -175
  28. data/core/integer.rbs +85 -145
  29. data/core/io/buffer.rbs +187 -60
  30. data/core/io/wait.rbs +28 -16
  31. data/core/io.rbs +1859 -1389
  32. data/core/kernel.rbs +525 -961
  33. data/core/match_data.rbs +306 -142
  34. data/core/math.rbs +506 -234
  35. data/core/method.rbs +0 -24
  36. data/core/module.rbs +110 -17
  37. data/core/nil_class.rbs +2 -0
  38. data/core/numeric.rbs +76 -144
  39. data/core/object.rbs +88 -212
  40. data/core/proc.rbs +17 -5
  41. data/core/process.rbs +22 -5
  42. data/core/ractor.rbs +1 -1
  43. data/core/random.rbs +20 -3
  44. data/core/range.rbs +91 -89
  45. data/core/rational.rbs +2 -3
  46. data/core/rbs/unnamed/argf.rbs +177 -120
  47. data/core/rbs/unnamed/env_class.rbs +89 -163
  48. data/core/rbs/unnamed/random.rbs +36 -12
  49. data/core/refinement.rbs +8 -0
  50. data/core/regexp.rbs +462 -272
  51. data/core/ruby_vm.rbs +210 -0
  52. data/{stdlib/set/0 → core}/set.rbs +43 -47
  53. data/core/string.rbs +1403 -1332
  54. data/core/string_io.rbs +191 -107
  55. data/core/struct.rbs +67 -63
  56. data/core/symbol.rbs +187 -201
  57. data/core/thread.rbs +40 -35
  58. data/core/time.rbs +902 -826
  59. data/core/trace_point.rbs +55 -6
  60. data/core/unbound_method.rbs +48 -24
  61. data/docs/collection.md +4 -0
  62. data/docs/syntax.md +55 -0
  63. data/ext/rbs_extension/parser.c +5 -6
  64. data/lib/rbs/cli.rb +6 -1
  65. data/lib/rbs/collection/cleaner.rb +8 -1
  66. data/lib/rbs/collection/config/lockfile.rb +3 -1
  67. data/lib/rbs/collection/config/lockfile_generator.rb +16 -14
  68. data/lib/rbs/collection/config.rb +1 -1
  69. data/lib/rbs/collection/sources/git.rb +9 -2
  70. data/lib/rbs/collection/sources/local.rb +79 -0
  71. data/lib/rbs/collection/sources.rb +8 -1
  72. data/lib/rbs/environment.rb +6 -5
  73. data/lib/rbs/environment_loader.rb +3 -2
  74. data/lib/rbs/errors.rb +18 -0
  75. data/lib/rbs/locator.rb +26 -7
  76. data/lib/rbs/sorter.rb +2 -2
  77. data/lib/rbs/version.rb +1 -1
  78. data/sig/collection/sources.rbs +32 -3
  79. data/sig/environment.rbs +2 -3
  80. data/sig/locator.rbs +14 -2
  81. data/sig/shims/{abstract_syntax_tree.rbs → _abstract_syntax_tree.rbs} +0 -0
  82. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -13
  83. data/stdlib/cgi/0/core.rbs +16 -0
  84. data/stdlib/coverage/0/coverage.rbs +50 -8
  85. data/stdlib/csv/0/csv.rbs +1 -1
  86. data/stdlib/date/0/date.rbs +856 -726
  87. data/stdlib/date/0/date_time.rbs +83 -210
  88. data/stdlib/erb/0/erb.rbs +13 -36
  89. data/stdlib/etc/0/etc.rbs +127 -20
  90. data/stdlib/fileutils/0/fileutils.rbs +1290 -381
  91. data/stdlib/logger/0/logger.rbs +466 -316
  92. data/stdlib/net-http/0/net-http.rbs +2211 -534
  93. data/stdlib/nkf/0/nkf.rbs +5 -5
  94. data/stdlib/objspace/0/objspace.rbs +31 -14
  95. data/stdlib/openssl/0/openssl.rbs +11 -7
  96. data/stdlib/optparse/0/optparse.rbs +20 -17
  97. data/stdlib/pathname/0/pathname.rbs +21 -4
  98. data/stdlib/pstore/0/pstore.rbs +378 -154
  99. data/stdlib/pty/0/pty.rbs +24 -8
  100. data/stdlib/ripper/0/ripper.rbs +1650 -0
  101. data/stdlib/socket/0/addrinfo.rbs +9 -15
  102. data/stdlib/socket/0/socket.rbs +36 -3
  103. data/stdlib/strscan/0/string_scanner.rbs +7 -5
  104. data/stdlib/tempfile/0/tempfile.rbs +104 -44
  105. data/stdlib/time/0/time.rbs +2 -2
  106. data/stdlib/uri/0/file.rbs +5 -0
  107. data/stdlib/uri/0/generic.rbs +2 -2
  108. data/stdlib/yaml/0/yaml.rbs +2 -2
  109. data/stdlib/zlib/0/zlib.rbs +1 -1
  110. metadata +8 -6
  111. data/core/deprecated.rbs +0 -9
  112. data/sig/shims/ripper.rbs +0 -8
@@ -55,107 +55,283 @@ module Net
55
55
  end
56
56
 
57
57
  # <!-- rdoc-file=lib/net/http.rb -->
58
- # ## An HTTP client API for Ruby.
58
+ # Class Net::HTTP provides a rich library that implements the client in a
59
+ # client-server model that uses the HTTP request-response protocol. For
60
+ # information about HTTP, see
61
+ #
62
+ # * [Hypertext Transfer
63
+ # Protocol](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol).
64
+ # * [Technical
65
+ # overview](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Techni
66
+ # cal_overview).
67
+ #
68
+ #
69
+ # Note: If you are performing only a few GET requests, consider using
70
+ # [OpenURI](rdoc-ref:OpenURI); otherwise, read on.
71
+ #
72
+ # ## Synopsis
73
+ #
74
+ # If you are already familiar with HTTP, this synopsis may be helpful.
75
+ #
76
+ # [Session](rdoc-ref:Net::HTTP@Sessions) with multiple requests for [HTTP
77
+ # methods](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_met
78
+ # hods):
79
+ #
80
+ # Net::HTTP.start(hostname) do |http|
81
+ # # Session started automatically before block execution.
82
+ # http.get(path_or_uri, headers = {})
83
+ # http.head(path_or_uri, headers = {})
84
+ # http.post(path_or_uri, data, headers = {}) # Can also have a block.
85
+ # http.put(path_or_uri, data, headers = {})
86
+ # http.delete(path_or_uri, headers = {Depth: 'Infinity'})
87
+ # http.options(path_or_uri, headers = {})
88
+ # http.trace(path_or_uri, headers = {})
89
+ # http.patch(path_or_uri, data, headers = {}) # Can also have a block.
90
+ # # Session finished automatically at block exit.
91
+ # end
92
+ #
93
+ # [Session](rdoc-ref:Net::HTTP@Sessions) with multiple requests for [WebDAV
94
+ # methods](https://en.wikipedia.org/wiki/WebDAV#Implementation):
95
+ #
96
+ # Net::HTTP.start(hostname) do |http|
97
+ # # Session started automatically before block execution.
98
+ # http.copy(path_or_uri, headers = {})
99
+ # http.lock(path_or_uri, body, headers = {})
100
+ # http.mkcol(path_or_uri, body = nil, headers = {})
101
+ # http.move(path_or_uri, headers = {})
102
+ # http.propfind(path_or_uri, body = nil, headers = {'Depth' => '0'})
103
+ # http.proppatch(path_or_uri, body, headers = {})
104
+ # http.unlock(path_or_uri, body, headers = {})
105
+ # # Session finished automatically at block exit.
106
+ # end
107
+ #
108
+ # Each of the following methods automatically starts and finishes a
109
+ # [session](rdoc-ref:Net::HTTP@Sessions) that sends a single request:
59
110
  #
60
- # Net::HTTP provides a rich library which can be used to build HTTP user-agents.
61
- # For more details about HTTP see
62
- # [RFC2616](http://www.ietf.org/rfc/rfc2616.txt).
111
+ # # Return string response body.
112
+ # Net::HTTP.get(hostname, path, port = 80)
113
+ # Net::HTTP.get(uri, headers = {}, port = 80)
63
114
  #
64
- # Net::HTTP is designed to work closely with URI. URI::HTTP#host,
65
- # URI::HTTP#port and URI::HTTP#request_uri are designed to work with Net::HTTP.
115
+ # # Write string response body to $stdout.
116
+ # Net::HTTP.get_print(hostname, path_or_uri, port = 80)
117
+ # Net::HTTP.get_print(uri, headers = {}, port = 80)
66
118
  #
67
- # If you are only performing a few GET requests you should try OpenURI.
119
+ # # Return response as Net::HTTPResponse object.
120
+ # Net::HTTP.get_response(hostname, path_or_uri, port = 80)
121
+ # Net::HTTP.get_response(uri, headers = {}, port = 80)
68
122
  #
69
- # ## Simple Examples
123
+ # Net::HTTP.post(uri, data, headers = {})
124
+ # Net::HTTP.post_form(uri, params)
70
125
  #
71
- # All examples assume you have loaded Net::HTTP with:
126
+ # ## About the Examples
127
+ #
128
+ # Examples here assume that `net/http` has been required (which also requires
129
+ # `uri`):
72
130
  #
73
131
  # require 'net/http'
74
132
  #
75
- # This will also require 'uri' so you don't need to require it separately.
133
+ # Many code examples here use these example websites:
76
134
  #
77
- # The Net::HTTP methods in the following section do not persist connections.
78
- # They are not recommended if you are performing many HTTP requests.
135
+ # * https://jsonplaceholder.typicode.com.
136
+ # * http://example.com.
79
137
  #
80
- # ### GET
81
138
  #
82
- # Net::HTTP.get('example.com', '/index.html') # => String
139
+ # Some examples also assume these variables:
83
140
  #
84
- # ### GET by URI
141
+ # uri = URI('https://jsonplaceholder.typicode.com')
142
+ # uri.freeze # Examples may not modify.
143
+ # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
144
+ # port = uri.port # => 443
85
145
  #
86
- # uri = URI('http://example.com/index.html?count=10')
87
- # Net::HTTP.get(uri) # => String
146
+ # So that example requests may be written as:
88
147
  #
89
- # ### GET with Dynamic Parameters
148
+ # Net::HTTP.get(uri)
149
+ # Net::HTTP.get(hostname, '/index.html')
150
+ # Net::HTTP.start(hostname) do |http|
151
+ # http.get('/todos/1')
152
+ # http.get('/todos/2')
153
+ # end
90
154
  #
91
- # uri = URI('http://example.com/index.html')
92
- # params = { :limit => 10, :page => 3 }
93
- # uri.query = URI.encode_www_form(params)
155
+ # An example that needs a modified URI first duplicates `uri`, then modifies the
156
+ # duplicate:
94
157
  #
95
- # res = Net::HTTP.get_response(uri)
96
- # puts res.body if res.is_a?(Net::HTTPSuccess)
158
+ # _uri = uri.dup
159
+ # _uri.path = '/todos/1'
97
160
  #
98
- # ### POST
161
+ # ## URIs
99
162
  #
100
- # uri = URI('http://www.example.com/search.cgi')
101
- # res = Net::HTTP.post_form(uri, 'q' => 'ruby', 'max' => '50')
102
- # puts res.body
163
+ # On the internet, a URI ([Universal Resource
164
+ # Identifier](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier)) is a
165
+ # string that identifies a particular resource. It consists of some or all of:
166
+ # scheme, hostname, path, query, and fragment; see [URI
167
+ # syntax](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax).
103
168
  #
104
- # ### POST with Multiple Values
169
+ # A Ruby [URI::Generic](rdoc-ref:URI::Generic) object represents an internet
170
+ # URI. It provides, among others, methods `scheme`, `hostname`, `path`, `query`,
171
+ # and `fragment`.
105
172
  #
106
- # uri = URI('http://www.example.com/search.cgi')
107
- # res = Net::HTTP.post_form(uri, 'q' => ['ruby', 'perl'], 'max' => '50')
108
- # puts res.body
173
+ # ### Schemes
109
174
  #
110
- # ## How to use Net::HTTP
175
+ # An internet URI has a
176
+ # [scheme](https://en.wikipedia.org/wiki/List_of_URI_schemes).
111
177
  #
112
- # The following example code can be used as the basis of an HTTP user-agent
113
- # which can perform a variety of request types using persistent connections.
178
+ # The two schemes supported in Net::HTTP are `'https'` and `'http'`:
114
179
  #
115
- # uri = URI('http://example.com/some_path?query=string')
180
+ # uri.scheme # => "https"
181
+ # URI('http://example.com').scheme # => "http"
116
182
  #
117
- # Net::HTTP.start(uri.host, uri.port) do |http|
118
- # request = Net::HTTP::Get.new uri
183
+ # ### Hostnames
119
184
  #
120
- # response = http.request request # Net::HTTPResponse object
185
+ # A hostname identifies a server (host) to which requests may be sent:
186
+ #
187
+ # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
188
+ # Net::HTTP.start(hostname) do |http|
189
+ # # Some HTTP stuff.
121
190
  # end
122
191
  #
123
- # Net::HTTP::start immediately creates a connection to an HTTP server which is
124
- # kept open for the duration of the block. The connection will remain open for
125
- # multiple requests in the block if the server indicates it supports persistent
126
- # connections.
192
+ # ### Paths
127
193
  #
128
- # If you wish to re-use a connection across multiple HTTP requests without
129
- # automatically closing it you can use ::new and then call #start and #finish
130
- # manually.
194
+ # A host-specific path identifies a resource on the host:
131
195
  #
132
- # The request types Net::HTTP supports are listed below in the section "HTTP
133
- # Request Classes".
196
+ # _uri = uri.dup
197
+ # _uri.path = '/todos/1'
198
+ # hostname = _uri.hostname
199
+ # path = _uri.path
200
+ # Net::HTTP.get(hostname, path)
134
201
  #
135
- # For all the Net::HTTP request objects and shortcut request methods you may
136
- # supply either a String for the request path or a URI from which Net::HTTP will
137
- # extract the request path.
202
+ # ### Queries
138
203
  #
139
- # ### Response Data
204
+ # A host-specific query adds name/value pairs to the URI:
140
205
  #
141
- # uri = URI('http://example.com/index.html')
142
- # res = Net::HTTP.get_response(uri)
206
+ # _uri = uri.dup
207
+ # params = {userId: 1, completed: false}
208
+ # _uri.query = URI.encode_www_form(params)
209
+ # _uri # => #<URI::HTTPS https://jsonplaceholder.typicode.com?userId=1&completed=false>
210
+ # Net::HTTP.get(_uri)
143
211
  #
144
- # # Headers
145
- # res['Set-Cookie'] # => String
146
- # res.get_fields('set-cookie') # => Array
147
- # res.to_hash['set-cookie'] # => Array
148
- # puts "Headers: #{res.to_hash.inspect}"
212
+ # ### Fragments
149
213
  #
150
- # # Status
151
- # puts res.code # => '200'
152
- # puts res.message # => 'OK'
153
- # puts res.class.name # => 'HTTPOK'
214
+ # A [URI fragment](https://en.wikipedia.org/wiki/URI_fragment) has no effect in
215
+ # Net::HTTP; the same data is returned, regardless of whether a fragment is
216
+ # included.
154
217
  #
155
- # # Body
156
- # puts res.body
218
+ # ## Request Headers
219
+ #
220
+ # Request headers may be used to pass additional information to the host,
221
+ # similar to arguments passed in a method call; each header is a name/value
222
+ # pair.
223
+ #
224
+ # Each of the Net::HTTP methods that sends a request to the host has optional
225
+ # argument `headers`, where the headers are expressed as a hash of
226
+ # field-name/value pairs:
227
+ #
228
+ # headers = {Accept: 'application/json', Connection: 'Keep-Alive'}
229
+ # Net::HTTP.get(uri, headers)
230
+ #
231
+ # See lists of both standard request fields and common request fields at
232
+ # [Request
233
+ # Fields](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_field
234
+ # s). A host may also accept other custom fields.
235
+ #
236
+ # ## Sessions
237
+ #
238
+ # A *session* is a connection between a server (host) and a client that:
239
+ #
240
+ # * Is begun by instance method Net::HTTP#start.
241
+ # * May contain any number of requests.
242
+ # * Is ended by instance method Net::HTTP#finish.
243
+ #
244
+ #
245
+ # See example sessions at the [Synopsis](rdoc-ref:Net::HTTP@Synopsis).
246
+ #
247
+ # ### Session Using Net::HTTP.start
248
+ #
249
+ # If you have many requests to make to a single host (and port), consider using
250
+ # singleton method Net::HTTP.start with a block; the method handles the session
251
+ # automatically by:
252
+ #
253
+ # * Calling #start before block execution.
254
+ # * Executing the block.
255
+ # * Calling #finish after block execution.
256
+ #
257
+ #
258
+ # In the block, you can use these instance methods, each of which that sends a
259
+ # single request:
260
+ #
261
+ # * [HTTP
262
+ # methods](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request
263
+ # _methods):
264
+ #
265
+ # * #get, #request_get: GET.
266
+ # * #head, #request_head: HEAD.
267
+ # * #post, #request_post: POST.
268
+ # * #delete: DELETE.
269
+ # * #options: OPTIONS.
270
+ # * #trace: TRACE.
271
+ # * #patch: PATCH.
272
+ #
273
+ #
274
+ # * [WebDAV methods](https://en.wikipedia.org/wiki/WebDAV#Implementation):
157
275
  #
158
- # ### Following Redirection
276
+ # * #copy: COPY.
277
+ # * #lock: LOCK.
278
+ # * #mkcol: MKCOL.
279
+ # * #move: MOVE.
280
+ # * #propfind: PROPFIND.
281
+ # * #proppatch: PROPPATCH.
282
+ # * #unlock: UNLOCK.
283
+ #
284
+ #
285
+ #
286
+ # ### Session Using Net::HTTP.start and Net::HTTP.finish
287
+ #
288
+ # You can manage a session manually using methods #start and #finish:
289
+ #
290
+ # http = Net::HTTP.new(hostname)
291
+ # http.start
292
+ # http.get('/todos/1')
293
+ # http.get('/todos/2')
294
+ # http.delete('/posts/1')
295
+ # http.finish # Needed to free resources.
296
+ #
297
+ # ### Single-Request Session
298
+ #
299
+ # Certain convenience methods automatically handle a session by:
300
+ #
301
+ # * Creating an HTTP object
302
+ # * Starting a session.
303
+ # * Sending a single request.
304
+ # * Finishing the session.
305
+ # * Destroying the object.
306
+ #
307
+ #
308
+ # Such methods that send GET requests:
309
+ #
310
+ # * ::get: Returns the string response body.
311
+ # * ::get_print: Writes the string response body to $stdout.
312
+ # * ::get_response: Returns a Net::HTTPResponse object.
313
+ #
314
+ #
315
+ # Such methods that send POST requests:
316
+ #
317
+ # * ::post: Posts data to the host.
318
+ # * ::post_form: Posts form data to the host.
319
+ #
320
+ #
321
+ # ## HTTP Requests and Responses
322
+ #
323
+ # Many of the methods above are convenience methods, each of which sends a
324
+ # request and returns a string without directly using Net::HTTPRequest and
325
+ # Net::HTTPResponse objects.
326
+ #
327
+ # You can, however, directly create a request object, send the request, and
328
+ # retrieve the response object; see:
329
+ #
330
+ # * Net::HTTPRequest.
331
+ # * Net::HTTPResponse.
332
+ #
333
+ #
334
+ # ## Following Redirection
159
335
  #
160
336
  # Each Net::HTTPResponse object belongs to a class for its response code.
161
337
  #
@@ -186,56 +362,7 @@ module Net
186
362
  #
187
363
  # print fetch('http://www.ruby-lang.org')
188
364
  #
189
- # ### POST
190
- #
191
- # A POST can be made using the Net::HTTP::Post request class. This example
192
- # creates a URL encoded POST body:
193
- #
194
- # uri = URI('http://www.example.com/todo.cgi')
195
- # req = Net::HTTP::Post.new(uri)
196
- # req.set_form_data('from' => '2005-01-01', 'to' => '2005-03-31')
197
- #
198
- # res = Net::HTTP.start(uri.hostname, uri.port) do |http|
199
- # http.request(req)
200
- # end
201
- #
202
- # case res
203
- # when Net::HTTPSuccess, Net::HTTPRedirection
204
- # # OK
205
- # else
206
- # res.value
207
- # end
208
- #
209
- # To send multipart/form-data use Net::HTTPHeader#set_form:
210
- #
211
- # req = Net::HTTP::Post.new(uri)
212
- # req.set_form([['upload', File.open('foo.bar')]], 'multipart/form-data')
213
- #
214
- # Other requests that can contain a body such as PUT can be created in the same
215
- # way using the corresponding request class (Net::HTTP::Put).
216
- #
217
- # ### Setting Headers
218
- #
219
- # The following example performs a conditional GET using the If-Modified-Since
220
- # header. If the files has not been modified since the time in the header a Not
221
- # Modified response will be returned. See RFC 2616 section 9.3 for further
222
- # details.
223
- #
224
- # uri = URI('http://example.com/cached_response')
225
- # file = File.stat 'cached_response'
226
- #
227
- # req = Net::HTTP::Get.new(uri)
228
- # req['If-Modified-Since'] = file.mtime.rfc2822
229
- #
230
- # res = Net::HTTP.start(uri.hostname, uri.port) {|http|
231
- # http.request(req)
232
- # }
233
- #
234
- # open 'cached_response', 'w' do |io|
235
- # io.write res.body
236
- # end if res.is_a?(Net::HTTPSuccess)
237
- #
238
- # ### Basic Authentication
365
+ # ## Basic Authentication
239
366
  #
240
367
  # Basic authentication is performed according to
241
368
  # [RFC2617](http://www.ietf.org/rfc/rfc2617.txt).
@@ -250,7 +377,7 @@ module Net
250
377
  # }
251
378
  # puts res.body
252
379
  #
253
- # ### Streaming Response Bodies
380
+ # ## Streaming Response Bodies
254
381
  #
255
382
  # By default Net::HTTP reads an entire response into memory. If you are
256
383
  # handling large files or wish to implement a progress bar you can instead
@@ -270,7 +397,7 @@ module Net
270
397
  # end
271
398
  # end
272
399
  #
273
- # ### HTTPS
400
+ # ## HTTPS
274
401
  #
275
402
  # HTTPS is enabled for an HTTP connection by Net::HTTP#use_ssl=.
276
403
  #
@@ -291,7 +418,7 @@ module Net
291
418
  # In previous versions of Ruby you would need to require 'net/https' to use
292
419
  # HTTPS. This is no longer true.
293
420
  #
294
- # ### Proxies
421
+ # ## Proxies
295
422
  #
296
423
  # Net::HTTP will automatically create a proxy from the `http_proxy` environment
297
424
  # variable if it is present. To disable use of `http_proxy`, pass `nil` for the
@@ -309,7 +436,7 @@ module Net
309
436
  # See Net::HTTP.new for further details and examples such as proxies that
310
437
  # require a username and password.
311
438
  #
312
- # ### Compression
439
+ # ## Compression
313
440
  #
314
441
  # Net::HTTP automatically adds Accept-Encoding for compression of response
315
442
  # bodies and automatically decompresses gzip and deflate responses unless a
@@ -317,171 +444,6 @@ module Net
317
444
  #
318
445
  # Compression can be disabled through the Accept-Encoding: identity header.
319
446
  #
320
- # ## HTTP Request Classes
321
- #
322
- # Here is the HTTP request class hierarchy.
323
- #
324
- # * Net::HTTPRequest
325
- # * Net::HTTP::Get
326
- # * Net::HTTP::Head
327
- # * Net::HTTP::Post
328
- # * Net::HTTP::Patch
329
- # * Net::HTTP::Put
330
- # * Net::HTTP::Proppatch
331
- # * Net::HTTP::Lock
332
- # * Net::HTTP::Unlock
333
- # * Net::HTTP::Options
334
- # * Net::HTTP::Propfind
335
- # * Net::HTTP::Delete
336
- # * Net::HTTP::Move
337
- # * Net::HTTP::Copy
338
- # * Net::HTTP::Mkcol
339
- # * Net::HTTP::Trace
340
- #
341
- #
342
- #
343
- # ## HTTP Response Classes
344
- #
345
- # Here is HTTP response class hierarchy. All classes are defined in Net module
346
- # and are subclasses of Net::HTTPResponse.
347
- #
348
- # HTTPUnknownResponse
349
- # : For unhandled HTTP extensions
350
- # HTTPInformation
351
- # : 1xx
352
- # HTTPContinue
353
- # : 100
354
- # HTTPSwitchProtocol
355
- # : 101
356
- # HTTPProcessing
357
- # : 102
358
- # HTTPEarlyHints
359
- # : 103
360
- # HTTPSuccess
361
- # : 2xx
362
- # HTTPOK
363
- # : 200
364
- # HTTPCreated
365
- # : 201
366
- # HTTPAccepted
367
- # : 202
368
- # HTTPNonAuthoritativeInformation
369
- # : 203
370
- # HTTPNoContent
371
- # : 204
372
- # HTTPResetContent
373
- # : 205
374
- # HTTPPartialContent
375
- # : 206
376
- # HTTPMultiStatus
377
- # : 207
378
- # HTTPAlreadyReported
379
- # : 208
380
- # HTTPIMUsed
381
- # : 226
382
- # HTTPRedirection
383
- # : 3xx
384
- # HTTPMultipleChoices
385
- # : 300
386
- # HTTPMovedPermanently
387
- # : 301
388
- # HTTPFound
389
- # : 302
390
- # HTTPSeeOther
391
- # : 303
392
- # HTTPNotModified
393
- # : 304
394
- # HTTPUseProxy
395
- # : 305
396
- # HTTPTemporaryRedirect
397
- # : 307
398
- # HTTPPermanentRedirect
399
- # : 308
400
- # HTTPClientError
401
- # : 4xx
402
- # HTTPBadRequest
403
- # : 400
404
- # HTTPUnauthorized
405
- # : 401
406
- # HTTPPaymentRequired
407
- # : 402
408
- # HTTPForbidden
409
- # : 403
410
- # HTTPNotFound
411
- # : 404
412
- # HTTPMethodNotAllowed
413
- # : 405
414
- # HTTPNotAcceptable
415
- # : 406
416
- # HTTPProxyAuthenticationRequired
417
- # : 407
418
- # HTTPRequestTimeOut
419
- # : 408
420
- # HTTPConflict
421
- # : 409
422
- # HTTPGone
423
- # : 410
424
- # HTTPLengthRequired
425
- # : 411
426
- # HTTPPreconditionFailed
427
- # : 412
428
- # HTTPRequestEntityTooLarge
429
- # : 413
430
- # HTTPRequestURITooLong
431
- # : 414
432
- # HTTPUnsupportedMediaType
433
- # : 415
434
- # HTTPRequestedRangeNotSatisfiable
435
- # : 416
436
- # HTTPExpectationFailed
437
- # : 417
438
- # HTTPMisdirectedRequest
439
- # : 421
440
- # HTTPUnprocessableEntity
441
- # : 422
442
- # HTTPLocked
443
- # : 423
444
- # HTTPFailedDependency
445
- # : 424
446
- # HTTPUpgradeRequired
447
- # : 426
448
- # HTTPPreconditionRequired
449
- # : 428
450
- # HTTPTooManyRequests
451
- # : 429
452
- # HTTPRequestHeaderFieldsTooLarge
453
- # : 431
454
- # HTTPUnavailableForLegalReasons
455
- # : 451
456
- # HTTPServerError
457
- # : 5xx
458
- # HTTPInternalServerError
459
- # : 500
460
- # HTTPNotImplemented
461
- # : 501
462
- # HTTPBadGateway
463
- # : 502
464
- # HTTPServiceUnavailable
465
- # : 503
466
- # HTTPGatewayTimeOut
467
- # : 504
468
- # HTTPVersionNotSupported
469
- # : 505
470
- # HTTPVariantAlsoNegotiates
471
- # : 506
472
- # HTTPInsufficientStorage
473
- # : 507
474
- # HTTPLoopDetected
475
- # : 508
476
- # HTTPNotExtended
477
- # : 510
478
- # HTTPNetworkAuthenticationRequired
479
- # : 511
480
- #
481
- #
482
- # There is also the Net::HTTPBadResponse exception which is raised when there is
483
- # a protocol error.
484
- #
485
447
  class HTTP < Protocol
486
448
  # :stopdoc:
487
449
  VERSION: String
@@ -496,8 +458,7 @@ module Net
496
458
  # rdoc-file=lib/net/http.rb
497
459
  # - version_1_2()
498
460
  # -->
499
- # Turns on net/http 1.2 (Ruby 1.8) features. Defaults to ON in Ruby 1.8 or
500
- # later.
461
+ # Returns `true`; retained for compatibility.
501
462
  #
502
463
  def self.version_1_2: () -> ::TrueClass
503
464
 
@@ -505,7 +466,7 @@ module Net
505
466
  # rdoc-file=lib/net/http.rb
506
467
  # - version_1_2?()
507
468
  # -->
508
- # Returns true if net/http is in version 1.2 mode. Defaults to true.
469
+ # Returns `true`; retained for compatibility.
509
470
  #
510
471
  def self.version_1_2?: () -> ::TrueClass
511
472
 
@@ -522,65 +483,57 @@ module Net
522
483
 
523
484
  # <!--
524
485
  # rdoc-file=lib/net/http.rb
525
- # - get_print(uri_or_host, path_or_headers = nil, port = nil)
486
+ # - Net::HTTP.get_print(hostname, path, port = 80) -> nil
487
+ # - Net::HTTP:get_print(uri, headers = {}, port = uri.port) -> nil
526
488
  # -->
527
- # Gets the body text from the target and outputs it to $stdout. The target can
528
- # either be specified as (`uri`, `headers`), or as (`host`, `path`, `port` =
529
- # 80); so:
530
- #
531
- # Net::HTTP.get_print URI('http://www.example.com/index.html')
532
- #
533
- # or:
534
- #
535
- # Net::HTTP.get_print 'www.example.com', '/index.html'
536
- #
537
- # you can also specify request headers:
538
- #
539
- # Net::HTTP.get_print URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' }
489
+ # Like Net::HTTP.get, but writes the returned body to $stdout; returns `nil`.
540
490
  #
541
491
  def self.get_print: (URI::Generic uri, ?Hash[String, untyped] header) -> void
542
492
  | (String host, String path, ?Integer port) -> void
543
493
 
544
494
  # <!--
545
495
  # rdoc-file=lib/net/http.rb
546
- # - get(uri_or_host, path_or_headers = nil, port = nil)
496
+ # - Net::HTTP.get(hostname, path, port = 80) -> body
497
+ # - Net::HTTP:get(uri, headers = {}, port = uri.port) -> body
547
498
  # -->
548
- # Sends a GET request to the target and returns the HTTP response as a string.
549
- # The target can either be specified as (`uri`, `headers`), or as (`host`,
550
- # `path`, `port` = 80); so:
499
+ # Sends a GET request and returns the HTTP response body as a string.
551
500
  #
552
- # print Net::HTTP.get(URI('http://www.example.com/index.html'))
501
+ # With string arguments `hostname` and `path`:
502
+ #
503
+ # hostname = 'jsonplaceholder.typicode.com'
504
+ # path = '/todos/1'
505
+ # puts Net::HTTP.get(hostname, path)
506
+ #
507
+ # Output:
508
+ #
509
+ # {
510
+ # "userId": 1,
511
+ # "id": 1,
512
+ # "title": "delectus aut autem",
513
+ # "completed": false
514
+ # }
553
515
  #
554
- # or:
516
+ # With URI object `uri` and optional hash argument `headers`:
555
517
  #
556
- # print Net::HTTP.get('www.example.com', '/index.html')
518
+ # uri = URI('https://jsonplaceholder.typicode.com/todos/1')
519
+ # headers = {'Content-type' => 'application/json; charset=UTF-8'}
520
+ # Net::HTTP.get(uri, headers)
557
521
  #
558
- # you can also specify request headers:
522
+ # Related:
559
523
  #
560
- # Net::HTTP.get(URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' })
524
+ # * Net::HTTP::Get: request class for HTTP method `GET`.
525
+ # * Net::HTTP#get: convenience method for HTTP method `GET`.
561
526
  #
562
527
  def self.get: (URI::Generic uri, ?Hash[String, untyped] header) -> String
563
528
  | (String host, String path, ?Integer port) -> String
564
529
 
565
530
  # <!--
566
531
  # rdoc-file=lib/net/http.rb
567
- # - get_response(uri_or_host, path_or_headers = nil, port = nil, &block)
532
+ # - Net::HTTP.get_response(hostname, path, port = 80) -> http_response
533
+ # - Net::HTTP:get_response(uri, headers = {}, port = uri.port) -> http_response
568
534
  # -->
569
- # Sends a GET request to the target and returns the HTTP response as a
570
- # Net::HTTPResponse object. The target can either be specified as (`uri`,
571
- # `headers`), or as (`host`, `path`, `port` = 80); so:
572
- #
573
- # res = Net::HTTP.get_response(URI('http://www.example.com/index.html'))
574
- # print res.body
575
- #
576
- # or:
577
- #
578
- # res = Net::HTTP.get_response('www.example.com', '/index.html')
579
- # print res.body
580
- #
581
- # you can also specify request headers:
582
- #
583
- # Net::HTTP.get_response(URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' })
535
+ # Like Net::HTTP.get, but returns a Net::HTTPResponse object instead of the body
536
+ # string.
584
537
  #
585
538
  def self.get_response: (URI::Generic uri, ?Hash[String, untyped] header) ?{ (Net::HTTPResponse) -> void } -> Net::HTTPResponse
586
539
  | (String host, String path, ?Integer port) -> Net::HTTPResponse
@@ -589,16 +542,30 @@ module Net
589
542
  # rdoc-file=lib/net/http.rb
590
543
  # - post(url, data, header = nil)
591
544
  # -->
592
- # Posts data to the specified URI object.
545
+ # Posts data to a host; returns a Net::HTTPResponse object.
593
546
  #
594
- # Example:
547
+ # Argument `url` must be a URL; argument `data` must be a string:
548
+ #
549
+ # _uri = uri.dup
550
+ # _uri.path = '/posts'
551
+ # data = '{"title": "foo", "body": "bar", "userId": 1}'
552
+ # headers = {'content-type': 'application/json'}
553
+ # res = Net::HTTP.post(_uri, data, headers) # => #<Net::HTTPCreated 201 Created readbody=true>
554
+ # puts res.body
555
+ #
556
+ # Output:
595
557
  #
596
- # require 'net/http'
597
- # require 'uri'
558
+ # {
559
+ # "title": "foo",
560
+ # "body": "bar",
561
+ # "userId": 1,
562
+ # "id": 101
563
+ # }
564
+ #
565
+ # Related:
598
566
  #
599
- # Net::HTTP.post URI('http://www.example.com/api/search'),
600
- # { "q" => "ruby", "max" => "50" }.to_json,
601
- # "Content-Type" => "application/json"
567
+ # * Net::HTTP::Post: request class for HTTP method `POST`.
568
+ # * Net::HTTP#post: convenience method for HTTP method `POST`.
602
569
  #
603
570
  def self.post: (URI::Generic url, String data, ?Hash[String, untyped] header) -> Net::HTTPResponse
604
571
 
@@ -606,21 +573,24 @@ module Net
606
573
  # rdoc-file=lib/net/http.rb
607
574
  # - post_form(url, params)
608
575
  # -->
609
- # Posts HTML form data to the specified URI object. The form data must be
610
- # provided as a Hash mapping from String to String. Example:
576
+ # Posts data to a host; returns a Net::HTTPResponse object.
611
577
  #
612
- # { "cmd" => "search", "q" => "ruby", "max" => "50" }
578
+ # Argument `url` must be a URI; argument `data` must be a hash:
613
579
  #
614
- # This method also does Basic Authentication if and only if `url`.user exists.
615
- # But userinfo for authentication is deprecated (RFC3986). So this feature will
616
- # be removed.
617
- #
618
- # Example:
580
+ # _uri = uri.dup
581
+ # _uri.path = '/posts'
582
+ # data = {title: 'foo', body: 'bar', userId: 1}
583
+ # res = Net::HTTP.post_form(_uri, data) # => #<Net::HTTPCreated 201 Created readbody=true>
584
+ # puts res.body
619
585
  #
620
- # require 'net/http'
586
+ # Output:
621
587
  #
622
- # Net::HTTP.post_form URI('http://www.example.com/search.cgi'),
623
- # { "q" => "ruby", "max" => "50" }
588
+ # {
589
+ # "title": "foo",
590
+ # "body": "bar",
591
+ # "userId": "1",
592
+ # "id": 101
593
+ # }
624
594
  #
625
595
  def self.post_form: (URI::Generic url, Hash[String, untyped] params) -> Net::HTTPResponse
626
596
 
@@ -628,7 +598,9 @@ module Net
628
598
  # rdoc-file=lib/net/http.rb
629
599
  # - default_port()
630
600
  # -->
631
- # The default port to use for HTTP requests; defaults to 80.
601
+ # Returns intger `80`, the default port to use for HTTP requests:
602
+ #
603
+ # Net::HTTP.default_port # => 80
632
604
  #
633
605
  def self.default_port: () -> Integer
634
606
 
@@ -636,7 +608,9 @@ module Net
636
608
  # rdoc-file=lib/net/http.rb
637
609
  # - http_default_port()
638
610
  # -->
639
- # The default port to use for HTTP requests; defaults to 80.
611
+ # Returns integer `80`, the default port to use for HTTP requests:
612
+ #
613
+ # Net::HTTP.http_default_port # => 80
640
614
  #
641
615
  def self.http_default_port: () -> Integer
642
616
 
@@ -644,48 +618,100 @@ module Net
644
618
  # rdoc-file=lib/net/http.rb
645
619
  # - https_default_port()
646
620
  # -->
647
- # The default port to use for HTTPS requests; defaults to 443.
621
+ # Returns integer `443`, the default port to use for HTTPS requests:
622
+ #
623
+ # Net::HTTP.https_default_port # => 443
648
624
  #
649
625
  def self.https_default_port: () -> Integer
650
626
 
651
627
  # <!--
652
628
  # rdoc-file=lib/net/http.rb
653
- # - HTTP.start(address, port, p_addr, p_port, p_user, p_pass, &block)
654
- # - HTTP.start(address, port=nil, p_addr=:ENV, p_port=nil, p_user=nil, p_pass=nil, opt, &block)
655
- # -->
656
- # Creates a new Net::HTTP object, then additionally opens the TCP connection and
657
- # HTTP session.
658
- #
659
- # Arguments are the following:
660
- # *address*
661
- # : hostname or IP address of the server
662
- # *port*
663
- # : port of the server
664
- # *p_addr*
665
- # : address of proxy
666
- # *p_port*
667
- # : port of proxy
668
- # *p_user*
669
- # : user of proxy
670
- # *p_pass*
671
- # : pass of proxy
672
- # *opt*
673
- # : optional hash
674
- #
675
- #
676
- # *opt* sets following values by its accessor. The keys are ipaddr, ca_file,
677
- # ca_path, cert, cert_store, ciphers, keep_alive_timeout,
678
- # close_on_empty_response, key, open_timeout, read_timeout, write_timeout,
679
- # ssl_timeout, ssl_version, use_ssl, verify_callback, verify_depth and
680
- # verify_mode. If you set :use_ssl as true, you can use https and default value
681
- # of verify_mode is set as OpenSSL::SSL::VERIFY_PEER.
682
- #
683
- # If the optional block is given, the newly created Net::HTTP object is passed
684
- # to it and closed when the block finishes. In this case, the return value of
685
- # this method is the return value of the block. If no block is given, the
686
- # return value of this method is the newly created Net::HTTP object itself, and
687
- # the caller is responsible for closing it upon completion using the finish()
688
- # method.
629
+ # - HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) -> http
630
+ # - HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) {|http| ... } -> object
631
+ # -->
632
+ # Creates a new Net::HTTP object, `http`, via Net::HTTP.new:
633
+ #
634
+ # Net::HTTP.new(address, port, p_addr, p_port, p_user, p_pass)
635
+ #
636
+ # * For arguments `hostname` through `p_pass`, see Net::HTTP.new.
637
+ # * For argument `opts`, see below.
638
+ #
639
+ #
640
+ # Note: If `port` is `nil` and `opts[:use_ssl]` is a truthy value, the value
641
+ # passed to `new` is Net::HTTP.https_default_port, not `port`.
642
+ #
643
+ # With no block given:
644
+ #
645
+ # * Calls `http.start` with no block (see #start), which opens a TCP
646
+ # connection and HTTP session.
647
+ # * Returns `http`.
648
+ # * The caller should call #finish to close the session:
649
+ #
650
+ # http = Net::HTTP.start(hostname)
651
+ # http.started? # => true
652
+ # http.finish
653
+ # http.started? # => false
654
+ #
655
+ #
656
+ # With a block given:
657
+ #
658
+ # * Calls `http.start` with the block (see #start), which:
659
+ #
660
+ # * Opens a TCP connection and HTTP session.
661
+ # * Calls the block, which may make any number of requests to the host.
662
+ # * Closes the HTTP session and TCP connection on block exit.
663
+ # * Returns the block's value `object`.
664
+ #
665
+ #
666
+ # * Returns `object`.
667
+ #
668
+ #
669
+ # Example:
670
+ #
671
+ # hostname = 'jsonplaceholder.typicode.com'
672
+ # Net::HTTP.start(hostname) do |http|
673
+ # puts http.get('/todos/1').body
674
+ # puts http.get('/todos/2').body
675
+ # end
676
+ #
677
+ # Output:
678
+ #
679
+ # {
680
+ # "userId": 1,
681
+ # "id": 1,
682
+ # "title": "delectus aut autem",
683
+ # "completed": false
684
+ # }
685
+ # {
686
+ # "userId": 1,
687
+ # "id": 2,
688
+ # "title": "quis ut nam facilis et officia qui",
689
+ # "completed": false
690
+ # }
691
+ #
692
+ # If the last argument given is a hash, it is the `opts` hash, where each key is
693
+ # a method or accessor to be called, and its value is the value to be set.
694
+ #
695
+ # The keys may include:
696
+ #
697
+ # * #ca_file
698
+ # * #ca_path
699
+ # * #cert
700
+ # * #cert_store
701
+ # * #ciphers
702
+ # * #close_on_empty_response
703
+ # * `ipaddr` (calls #ipaddr=)
704
+ # * #keep_alive_timeout
705
+ # * #key
706
+ # * #open_timeout
707
+ # * #read_timeout
708
+ # * #ssl_timeout
709
+ # * #ssl_version
710
+ # * `use_ssl` (calls #use_ssl=)
711
+ # * #verify_callback
712
+ # * #verify_depth
713
+ # * #verify_mode
714
+ # * #write_timeout
689
715
  #
690
716
  def self.start: (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?Hash[Symbol, untyped]? opt) -> Net::HTTP
691
717
  | [T] (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?Hash[Symbol, untyped]? opt) { (Net::HTTP) -> T } -> T
@@ -711,6 +737,10 @@ module Net
711
737
  # rdoc-file=lib/net/http.rb
712
738
  # - inspect()
713
739
  # -->
740
+ # Returns a string representation of `self`:
741
+ #
742
+ # Net::HTTP.new(hostname).inspect
743
+ # # => "#<Net::HTTP jsonplaceholder.typicode.com:80 open=false>"
714
744
  #
715
745
  def inspect: () -> String
716
746
 
@@ -721,11 +751,51 @@ module Net
721
751
  # **WARNING** This method opens a serious security hole. Never use this method
722
752
  # in production code.
723
753
  #
724
- # Sets an output stream for debugging.
754
+ # Sets the output stream for debugging:
725
755
  #
726
756
  # http = Net::HTTP.new(hostname)
727
- # http.set_debug_output $stderr
728
- # http.start { .... }
757
+ # File.open('t.tmp', 'w') do |file|
758
+ # http.set_debug_output(file)
759
+ # http.start
760
+ # http.get('/nosuch/1')
761
+ # http.finish
762
+ # end
763
+ # puts File.read('t.tmp')
764
+ #
765
+ # Output:
766
+ #
767
+ # opening connection to jsonplaceholder.typicode.com:80...
768
+ # opened
769
+ # <- "GET /nosuch/1 HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: jsonplaceholder.typicode.com\r\n\r\n"
770
+ # -> "HTTP/1.1 404 Not Found\r\n"
771
+ # -> "Date: Mon, 12 Dec 2022 21:14:11 GMT\r\n"
772
+ # -> "Content-Type: application/json; charset=utf-8\r\n"
773
+ # -> "Content-Length: 2\r\n"
774
+ # -> "Connection: keep-alive\r\n"
775
+ # -> "X-Powered-By: Express\r\n"
776
+ # -> "X-Ratelimit-Limit: 1000\r\n"
777
+ # -> "X-Ratelimit-Remaining: 999\r\n"
778
+ # -> "X-Ratelimit-Reset: 1670879660\r\n"
779
+ # -> "Vary: Origin, Accept-Encoding\r\n"
780
+ # -> "Access-Control-Allow-Credentials: true\r\n"
781
+ # -> "Cache-Control: max-age=43200\r\n"
782
+ # -> "Pragma: no-cache\r\n"
783
+ # -> "Expires: -1\r\n"
784
+ # -> "X-Content-Type-Options: nosniff\r\n"
785
+ # -> "Etag: W/\"2-vyGp6PvFo4RvsFtPoIWeCReyIC8\"\r\n"
786
+ # -> "Via: 1.1 vegur\r\n"
787
+ # -> "CF-Cache-Status: MISS\r\n"
788
+ # -> "Server-Timing: cf-q-config;dur=1.3000000762986e-05\r\n"
789
+ # -> "Report-To: {\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=yOr40jo%2BwS1KHzhTlVpl54beJ5Wx2FcG4gGV0XVrh3X9OlR5q4drUn2dkt5DGO4GDcE%2BVXT7CNgJvGs%2BZleIyMu8CLieFiDIvOviOY3EhHg94m0ZNZgrEdpKD0S85S507l1vsEwEHkoTm%2Ff19SiO\"}],\"group\":\"cf-nel\",\"max_age\":604800}\r\n"
790
+ # -> "NEL: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\r\n"
791
+ # -> "Server: cloudflare\r\n"
792
+ # -> "CF-RAY: 778977dc484ce591-DFW\r\n"
793
+ # -> "alt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400\r\n"
794
+ # -> "\r\n"
795
+ # reading 2 bytes...
796
+ # -> "{}"
797
+ # read 2 bytes
798
+ # Conn keep-alive
729
799
  #
730
800
  def set_debug_output: (IO output) -> void
731
801
 
@@ -771,13 +841,35 @@ module Net
771
841
  # rdoc-file=lib/net/http.rb
772
842
  # - ipaddr()
773
843
  # -->
774
- # The IP address to connect to/used to connect to
844
+ # Returns the IP address for the connection.
845
+ #
846
+ # If the session has not been started, returns the value set by #ipaddr=, or
847
+ # `nil` if it has not been set:
848
+ #
849
+ # http = Net::HTTP.new(hostname)
850
+ # http.ipaddr # => nil
851
+ # http.ipaddr = '172.67.155.76'
852
+ # http.ipaddr # => "172.67.155.76"
853
+ #
854
+ # If the session has been started, returns the IP address from the socket:
855
+ #
856
+ # http = Net::HTTP.new(hostname)
857
+ # http.start
858
+ # http.ipaddr # => "172.67.155.76"
859
+ # http.finish
775
860
  # ----
776
861
  # <!--
777
862
  # rdoc-file=lib/net/http.rb
778
863
  # - ipaddr=(addr)
779
864
  # -->
780
- # Set the IP address to connect to
865
+ # Sets the IP address for the connection:
866
+ #
867
+ # http = Net::HTTP.new(hostname)
868
+ # http.ipaddr # => nil
869
+ # http.ipaddr = '172.67.155.76'
870
+ # http.ipaddr # => "172.67.155.76"
871
+ #
872
+ # The IP address may not be set if the session has been started.
781
873
  #
782
874
  attr_accessor ipaddr: String?
783
875
 
@@ -799,7 +891,16 @@ module Net
799
891
  # rdoc-file=lib/net/http.rb
800
892
  # - read_timeout=(sec)
801
893
  # -->
802
- # Setter for the read_timeout attribute.
894
+ # Sets the read timeout, in seconds, for `self` to integer `sec`; the initial
895
+ # value is 60.
896
+ #
897
+ # Argument `sec` must be a non-negative numeric value:
898
+ #
899
+ # http = Net::HTTP.new(hostname)
900
+ # http.read_timeout # => 60
901
+ # http.get('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
902
+ # http.read_timeout = 0
903
+ # http.get('/todos/1') # Raises Net::ReadTimeout.
803
904
  #
804
905
  attr_accessor read_timeout: Float | Integer
805
906
 
@@ -814,7 +915,10 @@ module Net
814
915
  # rdoc-file=lib/net/http.rb
815
916
  # - write_timeout=(sec)
816
917
  # -->
817
- # Setter for the write_timeout attribute.
918
+ # Sets the write timeout, in seconds, for `self` to integer `sec`; the initial
919
+ # value is 60.
920
+ #
921
+ # Argument `sec` must be a non-negative numeric value.
818
922
  #
819
923
  attr_accessor write_timeout: Float | Integer
820
924
 
@@ -822,10 +926,15 @@ module Net
822
926
  # rdoc-file=lib/net/http.rb
823
927
  # - max_retries=(retries)
824
928
  # -->
825
- # Maximum number of times to retry an idempotent request in case of
929
+ # Sets the maximum number of times to retry an idempotent request in case of
826
930
  # Net::ReadTimeout, IOError, EOFError, Errno::ECONNRESET, Errno::ECONNABORTED,
827
- # Errno::EPIPE, OpenSSL::SSL::SSLError, Timeout::Error. Should be a non-negative
828
- # integer number. Zero means no retries. The default value is 1.
931
+ # Errno::EPIPE, OpenSSL::SSL::SSLError, Timeout::Error. The initial value is 1.
932
+ #
933
+ # Argument `retries` must be a non-negative numeric value:
934
+ #
935
+ # http = Net::HTTP.new(hostname)
936
+ # http.max_retries = 2 # => 2
937
+ # http.max_retries # => 2
829
938
  #
830
939
  attr_accessor max_retries: Integer
831
940
 
@@ -1486,12 +1595,234 @@ module Net
1486
1595
  end
1487
1596
 
1488
1597
  # <!-- rdoc-file=lib/net/http/header.rb -->
1489
- # The HTTPHeader module defines methods for reading and writing HTTP headers.
1598
+ # The HTTPHeader module provides access to HTTP headers.
1599
+ #
1600
+ # The module is included in:
1601
+ #
1602
+ # * Net::HTTPGenericRequest (and therefore Net::HTTPRequest).
1603
+ # * Net::HTTPResponse.
1604
+ #
1605
+ #
1606
+ # The headers are a hash-like collection of key/value pairs called *fields*.
1607
+ #
1608
+ # ## Request and Response Fields
1609
+ #
1610
+ # Headers may be included in:
1611
+ #
1612
+ # * A Net::HTTPRequest object: the object's headers will be sent with the
1613
+ # request. Any fields may be defined in the request; see
1614
+ # [Setters](rdoc-ref:Net::HTTPHeader@Setters).
1615
+ # * A Net::HTTPResponse object: the objects headers are usually those returned
1616
+ # from the host. Fields may be retrieved from the object; see
1617
+ # [Getters](rdoc-ref:Net::HTTPHeader@Getters) and
1618
+ # [Iterators](rdoc-ref:Net::HTTPHeader@Iterators).
1619
+ #
1620
+ #
1621
+ # Exactly which fields should be sent or expected depends on the host; see:
1622
+ #
1623
+ # * [Request
1624
+ # fields](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_f
1625
+ # ields).
1626
+ # * [Response
1627
+ # fields](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Response_
1628
+ # fields).
1629
+ #
1630
+ #
1631
+ # ## About the Examples
1632
+ #
1633
+ # Examples here assume that `net/http` has been required (which also requires
1634
+ # `uri`):
1635
+ #
1636
+ # require 'net/http'
1637
+ #
1638
+ # Many code examples here use these example websites:
1639
+ #
1640
+ # * https://jsonplaceholder.typicode.com.
1641
+ # * http://example.com.
1642
+ #
1643
+ #
1644
+ # Some examples also assume these variables:
1645
+ #
1646
+ # uri = URI('https://jsonplaceholder.typicode.com')
1647
+ # uri.freeze # Examples may not modify.
1648
+ # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
1649
+ # port = uri.port # => 443
1650
+ #
1651
+ # So that example requests may be written as:
1652
+ #
1653
+ # Net::HTTP.get(uri)
1654
+ # Net::HTTP.get(hostname, '/index.html')
1655
+ # Net::HTTP.start(hostname) do |http|
1656
+ # http.get('/todos/1')
1657
+ # http.get('/todos/2')
1658
+ # end
1659
+ #
1660
+ # An example that needs a modified URI first duplicates `uri`, then modifies the
1661
+ # duplicate:
1662
+ #
1663
+ # _uri = uri.dup
1664
+ # _uri.path = '/todos/1'
1665
+ #
1666
+ # ## Fields
1667
+ #
1668
+ # A header field is a key/value pair.
1669
+ #
1670
+ # ### Field Keys
1671
+ #
1672
+ # A field key may be:
1673
+ #
1674
+ # * A string: Key `'Accept'` is treated as if it were `'Accept'.downcase`;
1675
+ # i.e., `'accept'`.
1676
+ # * A symbol: Key `:Accept` is treated as if it were `:Accept.to_s.downcase`;
1677
+ # i.e., `'accept'`.
1678
+ #
1679
+ #
1680
+ # Examples:
1681
+ #
1682
+ # req = Net::HTTP::Get.new(uri)
1683
+ # req[:accept] # => "*/*"
1684
+ # req['Accept'] # => "*/*"
1685
+ # req['ACCEPT'] # => "*/*"
1686
+ #
1687
+ # req['accept'] = 'text/html'
1688
+ # req[:accept] = 'text/html'
1689
+ # req['ACCEPT'] = 'text/html'
1690
+ #
1691
+ # ### Field Values
1692
+ #
1693
+ # A field value may be returned as an array of strings or as a string:
1694
+ #
1695
+ # * These methods return field values as arrays:
1696
+ #
1697
+ # * #get_fields: Returns the array value for the given key, or `nil` if it
1698
+ # does not exist.
1699
+ # * #to_hash: Returns a hash of all header fields: each key is a field
1700
+ # name; its value is the array value for the field.
1701
+ #
1702
+ #
1703
+ # * These methods return field values as string; the string value for a field
1704
+ # is equivalent to `self[key.downcase.to_s].join(', '))`:
1705
+ #
1706
+ # * #[]: Returns the string value for the given key, or `nil` if it does
1707
+ # not exist.
1708
+ # * #fetch: Like #[], but accepts a default value to be returned if the
1709
+ # key does not exist.
1710
+ #
1711
+ #
1712
+ #
1713
+ # The field value may be set:
1714
+ #
1715
+ # * #[]=: Sets the value for the given key; the given value may be a string, a
1716
+ # symbol, an array, or a hash.
1717
+ # * #add_field: Adds a given value to a value for the given key (not
1718
+ # overwriting the existing value).
1719
+ # * #delete: Deletes the field for the given key.
1720
+ #
1721
+ #
1722
+ # Example field values:
1490
1723
  #
1491
- # It is used as a mixin by other classes, to provide hash-like access to HTTP
1492
- # header values. Unlike raw hash access, HTTPHeader provides access via
1493
- # case-insensitive keys. It also provides methods for accessing commonly-used
1494
- # HTTP header values in more convenient formats.
1724
+ # * String:
1725
+ #
1726
+ # req['Accept'] = 'text/html' # => "text/html"
1727
+ # req['Accept'] # => "text/html"
1728
+ # req.get_fields('Accept') # => ["text/html"]
1729
+ #
1730
+ # * Symbol:
1731
+ #
1732
+ # req['Accept'] = :text # => :text
1733
+ # req['Accept'] # => "text"
1734
+ # req.get_fields('Accept') # => ["text"]
1735
+ #
1736
+ # * Simple array:
1737
+ #
1738
+ # req[:foo] = %w[bar baz bat]
1739
+ # req[:foo] # => "bar, baz, bat"
1740
+ # req.get_fields(:foo) # => ["bar", "baz", "bat"]
1741
+ #
1742
+ # * Simple hash:
1743
+ #
1744
+ # req[:foo] = {bar: 0, baz: 1, bat: 2}
1745
+ # req[:foo] # => "bar, 0, baz, 1, bat, 2"
1746
+ # req.get_fields(:foo) # => ["bar", "0", "baz", "1", "bat", "2"]
1747
+ #
1748
+ # * Nested:
1749
+ #
1750
+ # req[:foo] = [%w[bar baz], {bat: 0, bam: 1}]
1751
+ # req[:foo] # => "bar, baz, bat, 0, bam, 1"
1752
+ # req.get_fields(:foo) # => ["bar", "baz", "bat", "0", "bam", "1"]
1753
+ #
1754
+ # req[:foo] = {bar: %w[baz bat], bam: {bah: 0, bad: 1}}
1755
+ # req[:foo] # => "bar, baz, bat, bam, bah, 0, bad, 1"
1756
+ # req.get_fields(:foo) # => ["bar", "baz", "bat", "bam", "bah", "0", "bad", "1"]
1757
+ #
1758
+ #
1759
+ # ## Convenience Methods
1760
+ #
1761
+ # Various convenience methods retrieve values, set values, query values, set
1762
+ # form values, or iterate over fields.
1763
+ #
1764
+ # ### Setters
1765
+ #
1766
+ # Method #[]= can set any field, but does little to validate the new value; some
1767
+ # of the other setter methods provide some validation:
1768
+ #
1769
+ # * #[]=: Sets the string or array value for the given key.
1770
+ # * #add_field: Creates or adds to the array value for the given key.
1771
+ # * #basic_auth: Sets the string authorization header for `'Authorization'`.
1772
+ # * #content_length=: Sets the integer length for field `'Content-Length`.
1773
+ # * #content_type=: Sets the string value for field `'Content-Type'`.
1774
+ # * #proxy_basic_auth: Sets the string authorization header for
1775
+ # `'Proxy-Authorization'`.
1776
+ # * #set_range: Sets the value for field `'Range'`.
1777
+ #
1778
+ #
1779
+ # ### Form Setters
1780
+ #
1781
+ # * #set_form: Sets an HTML form data set.
1782
+ # * #set_form_data: Sets header fields and a body from HTML form data.
1783
+ #
1784
+ #
1785
+ # ### Getters
1786
+ #
1787
+ # Method #[] can retrieve the value of any field that exists, but always as a
1788
+ # string; some of the other getter methods return something different from the
1789
+ # simple string value:
1790
+ #
1791
+ # * #[]: Returns the string field value for the given key.
1792
+ # * #content_length: Returns the integer value of field `'Content-Length'`.
1793
+ # * #content_range: Returns the Range value of field `'Content-Range'`.
1794
+ # * #content_type: Returns the string value of field `'Content-Type'`.
1795
+ # * #fetch: Returns the string field value for the given key.
1796
+ # * #get_fields: Returns the array field value for the given `key`.
1797
+ # * #main_type: Returns first part of the string value of field
1798
+ # `'Content-Type'`.
1799
+ # * #sub_type: Returns second part of the string value of field
1800
+ # `'Content-Type'`.
1801
+ # * #range: Returns an array of Range objects of field `'Range'`, or `nil`.
1802
+ # * #range_length: Returns the integer length of the range given in field
1803
+ # `'Content-Range'`.
1804
+ # * #type_params: Returns the string parameters for `'Content-Type'`.
1805
+ #
1806
+ #
1807
+ # ### Queries
1808
+ #
1809
+ # * #chunked?: Returns whether field `'Transfer-Encoding'` is set to
1810
+ # `'chunked'`.
1811
+ # * #connection_close?: Returns whether field `'Connection'` is set to
1812
+ # `'close'`.
1813
+ # * #connection_keep_alive?: Returns whether field `'Connection'` is set to
1814
+ # `'keep-alive'`.
1815
+ # * #key?: Returns whether a given key exists.
1816
+ #
1817
+ #
1818
+ # ### Iterators
1819
+ #
1820
+ # * #each_capitalized: Passes each field capitalized-name/value pair to the
1821
+ # block.
1822
+ # * #each_capitalized_name: Passes each capitalized field name to the block.
1823
+ # * #each_header: Passes each field name/value pair to the block.
1824
+ # * #each_name: Passes each field name to the block.
1825
+ # * #each_value: Passes each string field value to the block.
1495
1826
  #
1496
1827
  module HTTPHeader
1497
1828
  # <!--
@@ -1511,8 +1842,15 @@ module Net
1511
1842
  # rdoc-file=lib/net/http/header.rb
1512
1843
  # - [](key)
1513
1844
  # -->
1514
- # Returns the header field corresponding to the case-insensitive key. For
1515
- # example, a key of "Content-Type" might return "text/html"
1845
+ # Returns the string field value for the case-insensitive field `key`, or `nil`
1846
+ # if there is no such key; see [Fields](rdoc-ref:Net::HTTPHeader@Fields):
1847
+ #
1848
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
1849
+ # res['Connection'] # => "keep-alive"
1850
+ # res['Nosuch'] # => nil
1851
+ #
1852
+ # Note that some field values may be retrieved via convenience methods; see
1853
+ # [Getters](rdoc-ref:Net::HTTPHeader@Getters).
1516
1854
  #
1517
1855
  def []: (key key) -> (nil | String)
1518
1856
 
@@ -1520,7 +1858,17 @@ module Net
1520
1858
  # rdoc-file=lib/net/http/header.rb
1521
1859
  # - []=(key, val)
1522
1860
  # -->
1523
- # Sets the header field corresponding to the case-insensitive key.
1861
+ # Sets the value for the case-insensitive `key` to `val`, overwriting the
1862
+ # previous value if the field exists; see
1863
+ # [Fields](rdoc-ref:Net::HTTPHeader@Fields):
1864
+ #
1865
+ # req = Net::HTTP::Get.new(uri)
1866
+ # req['Accept'] # => "*/*"
1867
+ # req['Accept'] = 'text/html'
1868
+ # req['Accept'] # => "text/html"
1869
+ #
1870
+ # Note that some field values may be set via convenience methods; see
1871
+ # [Setters](rdoc-ref:Net::HTTPHeader@Setters).
1524
1872
  #
1525
1873
  def []=: (key key, untyped val) -> void
1526
1874
 
@@ -1528,20 +1876,18 @@ module Net
1528
1876
  # rdoc-file=lib/net/http/header.rb
1529
1877
  # - add_field(key, val)
1530
1878
  # -->
1531
- # Ruby 1.8.3
1532
- # : Adds a value to a named header field, instead of replacing its value.
1533
- # Second argument `val` must be a String. See also #[]=, #[] and
1534
- # #get_fields.
1535
- #
1536
- # request.add_field 'X-My-Header', 'a'
1537
- # p request['X-My-Header'] #=> "a"
1538
- # p request.get_fields('X-My-Header') #=> ["a"]
1539
- # request.add_field 'X-My-Header', 'b'
1540
- # p request['X-My-Header'] #=> "a, b"
1541
- # p request.get_fields('X-My-Header') #=> ["a", "b"]
1542
- # request.add_field 'X-My-Header', 'c'
1543
- # p request['X-My-Header'] #=> "a, b, c"
1544
- # p request.get_fields('X-My-Header') #=> ["a", "b", "c"]
1879
+ # Adds value `val` to the value array for field `key` if the field exists;
1880
+ # creates the field with the given `key` and `val` if it does not exist. see
1881
+ # [Fields](rdoc-ref:Net::HTTPHeader@Fields):
1882
+ #
1883
+ # req = Net::HTTP::Get.new(uri)
1884
+ # req.add_field('Foo', 'bar')
1885
+ # req['Foo'] # => "bar"
1886
+ # req.add_field('Foo', 'baz')
1887
+ # req['Foo'] # => "bar, baz"
1888
+ # req.add_field('Foo', %w[baz bam])
1889
+ # req['Foo'] # => "bar, baz, baz, bam"
1890
+ # req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"]
1545
1891
  #
1546
1892
  def add_field: (key key, untyped val) -> void
1547
1893
 
@@ -1567,26 +1913,42 @@ module Net
1567
1913
  # rdoc-file=lib/net/http/header.rb
1568
1914
  # - get_fields(key)
1569
1915
  # -->
1570
- # Ruby 1.8.3
1571
- # : Returns an array of header field strings corresponding to the
1572
- # case-insensitive `key`. This method allows you to get duplicated header
1573
- # fields without any processing. See also #[].
1916
+ # Returns the array field value for the given `key`, or `nil` if there is no
1917
+ # such field; see [Fields](rdoc-ref:Net::HTTPHeader@Fields):
1574
1918
  #
1575
- # p response.get_fields('Set-Cookie')
1576
- # #=> ["session=al98axx; expires=Fri, 31-Dec-1999 23:58:23",
1577
- # "query=rubyscript; expires=Fri, 31-Dec-1999 23:58:23"]
1578
- # p response['Set-Cookie']
1579
- # #=> "session=al98axx; expires=Fri, 31-Dec-1999 23:58:23, query=rubyscript; expires=Fri, 31-Dec-1999 23:58:23"
1919
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
1920
+ # res.get_fields('Connection') # => ["keep-alive"]
1921
+ # res.get_fields('Nosuch') # => nil
1580
1922
  #
1581
1923
  def get_fields: (key key) -> (nil | Array[String])
1582
1924
 
1583
1925
  # <!--
1584
1926
  # rdoc-file=lib/net/http/header.rb
1585
- # - fetch(key, *args) { |key| ... }
1927
+ # - fetch(key, default_val = nil) {|key| ... } -> object
1928
+ # - fetch(key, default_val = nil) -> value or default_val
1586
1929
  # -->
1587
- # Returns the header field corresponding to the case-insensitive key. Returns
1588
- # the default value `args`, or the result of the block, or raises an IndexError
1589
- # if there's no header field named `key` See Hash#fetch
1930
+ # With a block, returns the string value for `key` if it exists; otherwise
1931
+ # returns the value of the block; ignores the `default_val`; see
1932
+ # [Fields](rdoc-ref:Net::HTTPHeader@Fields):
1933
+ #
1934
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
1935
+ #
1936
+ # # Field exists; block not called.
1937
+ # res.fetch('Connection') do |value|
1938
+ # fail 'Cannot happen'
1939
+ # end # => "keep-alive"
1940
+ #
1941
+ # # Field does not exist; block called.
1942
+ # res.fetch('Nosuch') do |value|
1943
+ # value.downcase
1944
+ # end # => "nosuch"
1945
+ #
1946
+ # With no block, returns the string value for `key` if it exists; otherwise,
1947
+ # returns `default_val` if it was given; otherwise raises an exception:
1948
+ #
1949
+ # res.fetch('Connection', 'Foo') # => "keep-alive"
1950
+ # res.fetch('Nosuch', 'Foo') # => "Foo"
1951
+ # res.fetch('Nosuch') # Raises KeyError.
1590
1952
  #
1591
1953
  def fetch: (key key) -> String
1592
1954
  | (key key, untyped) -> untyped
@@ -1596,14 +1958,24 @@ module Net
1596
1958
  # rdoc-file=lib/net/http/header.rb
1597
1959
  # - each_header() { |key| ... }
1598
1960
  # -->
1599
- # Iterates through the header names and values, passing in the name and value to
1600
- # the code block supplied.
1961
+ # Calls the block with each key/value pair:
1601
1962
  #
1602
- # Returns an enumerator if no block is given.
1963
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
1964
+ # res.each_header do |key, value|
1965
+ # p [key, value] if key.start_with?('c')
1966
+ # end
1603
1967
  #
1604
- # Example:
1968
+ # Output:
1605
1969
  #
1606
- # response.header.each_header {|key,value| puts "#{key} = #{value}" }
1970
+ # ["content-type", "application/json; charset=utf-8"]
1971
+ # ["connection", "keep-alive"]
1972
+ # ["cache-control", "max-age=43200"]
1973
+ # ["cf-cache-status", "HIT"]
1974
+ # ["cf-ray", "771d17e9bc542cf5-ORD"]
1975
+ #
1976
+ # Returns an enumerator if no block is given.
1977
+ #
1978
+ # Net::HTTPHeader#each is an alias for Net::HTTPHeader#each_header.
1607
1979
  #
1608
1980
  def each_header: () { (String, String) -> untyped } -> Hash[String, Array[String]]
1609
1981
  | () -> Enumerator[[ String, String ], Hash[String, Array[String]]]
@@ -1619,11 +1991,25 @@ module Net
1619
1991
  # rdoc-file=lib/net/http/header.rb
1620
1992
  # - each_name() { |key| ... }
1621
1993
  # -->
1622
- # Iterates through the header names in the header, passing each header name to
1623
- # the code block.
1994
+ # Calls the block with each field key:
1995
+ #
1996
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
1997
+ # res.each_key do |key|
1998
+ # p key if key.start_with?('c')
1999
+ # end
2000
+ #
2001
+ # Output:
2002
+ #
2003
+ # "content-type"
2004
+ # "connection"
2005
+ # "cache-control"
2006
+ # "cf-cache-status"
2007
+ # "cf-ray"
1624
2008
  #
1625
2009
  # Returns an enumerator if no block is given.
1626
2010
  #
2011
+ # Net::HTTPHeader#each_name is an alias for Net::HTTPHeader#each_key.
2012
+ #
1627
2013
  def each_name: () { (String) -> untyped } -> Hash[String, Array[String]]
1628
2014
  | () -> Enumerator[String, Hash[String, Array[String]]]
1629
2015
 
@@ -1638,11 +2024,23 @@ module Net
1638
2024
  # rdoc-file=lib/net/http/header.rb
1639
2025
  # - each_capitalized_name() { |key| ... }
1640
2026
  # -->
1641
- # Iterates through the header names in the header, passing capitalized header
1642
- # names to the code block.
2027
+ # Calls the block with each capitalized field name:
2028
+ #
2029
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
2030
+ # res.each_capitalized_name do |key|
2031
+ # p key if key.start_with?('C')
2032
+ # end
1643
2033
  #
1644
- # Note that header names are capitalized systematically; capitalization may not
1645
- # match that used by the remote HTTP server in its response.
2034
+ # Output:
2035
+ #
2036
+ # "Content-Type"
2037
+ # "Connection"
2038
+ # "Cache-Control"
2039
+ # "Cf-Cache-Status"
2040
+ # "Cf-Ray"
2041
+ #
2042
+ # The capitalization is system-dependent; see [Case
2043
+ # Mapping](rdoc-ref:case_mapping.rdoc).
1646
2044
  #
1647
2045
  # Returns an enumerator if no block is given.
1648
2046
  #
@@ -1653,7 +2051,18 @@ module Net
1653
2051
  # rdoc-file=lib/net/http/header.rb
1654
2052
  # - each_value() { |value| ... }
1655
2053
  # -->
1656
- # Iterates through header values, passing each value to the code block.
2054
+ # Calls the block with each string field value:
2055
+ #
2056
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
2057
+ # res.each_value do |value|
2058
+ # p value if value.start_with?('c')
2059
+ # end
2060
+ #
2061
+ # Output:
2062
+ #
2063
+ # "chunked"
2064
+ # "cf-q-config;dur=6.0000002122251e-06"
2065
+ # "cloudflare"
1657
2066
  #
1658
2067
  # Returns an enumerator if no block is given.
1659
2068
  #
@@ -1664,7 +2073,13 @@ module Net
1664
2073
  # rdoc-file=lib/net/http/header.rb
1665
2074
  # - delete(key)
1666
2075
  # -->
1667
- # Removes a header field, specified by case-insensitive key.
2076
+ # Removes the header for the given case-insensitive `key` (see
2077
+ # [Fields](rdoc-ref:Net::HTTPHeader@Fields)); returns the deleted value, or
2078
+ # `nil` if no such field exists:
2079
+ #
2080
+ # req = Net::HTTP::Get.new(uri)
2081
+ # req.delete('Accept') # => ["*/*"]
2082
+ # req.delete('Nosuch') # => nil
1668
2083
  #
1669
2084
  def delete: (key key) -> (Array[String] | nil)
1670
2085
 
@@ -1672,7 +2087,12 @@ module Net
1672
2087
  # rdoc-file=lib/net/http/header.rb
1673
2088
  # - key?(key)
1674
2089
  # -->
1675
- # true if `key` header exists.
2090
+ # Returns `true` if the field for the case-insensitive `key` exists, `false`
2091
+ # otherwise:
2092
+ #
2093
+ # req = Net::HTTP::Get.new(uri)
2094
+ # req.key?('Accept') # => true
2095
+ # req.key?('Nosuch') # => false
1676
2096
  #
1677
2097
  def key?: (key key) -> bool
1678
2098
 
@@ -1680,10 +2100,15 @@ module Net
1680
2100
  # rdoc-file=lib/net/http/header.rb
1681
2101
  # - to_hash()
1682
2102
  # -->
1683
- # Returns a Hash consisting of header names and array of values. e.g.
1684
- # {"cache-control" => ["private"],
1685
- # "content-type" => ["text/html"],
1686
- # "date" => ["Wed, 22 Jun 2005 22:11:50 GMT"]}
2103
+ # Returns a hash of the key/value pairs:
2104
+ #
2105
+ # req = Net::HTTP::Get.new(uri)
2106
+ # req.to_hash
2107
+ # # =>
2108
+ # {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
2109
+ # "accept"=>["*/*"],
2110
+ # "user-agent"=>["Ruby"],
2111
+ # "host"=>["jsonplaceholder.typicode.com"]}
1687
2112
  #
1688
2113
  def to_hash: () -> Hash[String, Array[String]]
1689
2114
 
@@ -1691,12 +2116,10 @@ module Net
1691
2116
  # rdoc-file=lib/net/http/header.rb
1692
2117
  # - each_capitalized() { |capitalize(k), join(', ')| ... }
1693
2118
  # -->
1694
- # As for #each_header, except the keys are provided in capitalized form.
2119
+ # Like #each_header, but the keys are returned in capitalized form.
1695
2120
  #
1696
- # Note that header names are capitalized systematically; capitalization may not
1697
- # match that used by the remote HTTP server in its response.
1698
- #
1699
- # Returns an enumerator if no block is given.
2121
+ # Net::HTTPHeader#canonical_each is an alias for
2122
+ # Net::HTTPHeader#each_capitalized.
1700
2123
  #
1701
2124
  def each_capitalized: () { (String, String) -> untyped } -> Hash[String, Array[String]]
1702
2125
  | () -> Enumerator[[ String, String ], Hash[String, Array[String]]]
@@ -1723,26 +2146,52 @@ module Net
1723
2146
  # rdoc-file=lib/net/http/header.rb
1724
2147
  # - range()
1725
2148
  # -->
1726
- # Returns an Array of Range objects which represent the Range: HTTP header
1727
- # field, or `nil` if there is no such header.
2149
+ # Returns an array of Range objects that represent the value of field `'Range'`,
2150
+ # or `nil` if there is no such field; see [Range request
2151
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request
2152
+ # -header):
2153
+ #
2154
+ # req = Net::HTTP::Get.new(uri)
2155
+ # req['Range'] = 'bytes=0-99,200-299,400-499'
2156
+ # req.range # => [0..99, 200..299, 400..499]
2157
+ # req.delete('Range')
2158
+ # req.range # # => nil
1728
2159
  #
1729
2160
  def range: () -> (nil | Array[Range[Integer]])
1730
2161
 
1731
2162
  # <!--
1732
2163
  # rdoc-file=lib/net/http/header.rb
1733
- # - set_range(r, e = nil)
2164
+ # - set_range(length) -> length
2165
+ # - set_range(offset, length) -> range
2166
+ # - set_range(begin..length) -> range
1734
2167
  # -->
1735
- # Sets the HTTP Range: header. Accepts either a Range object as a single
1736
- # argument, or a beginning index and a length from that index. Example:
2168
+ # Sets the value for field `'Range'`; see [Range request
2169
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request
2170
+ # -header):
1737
2171
  #
1738
- # req.range = (0..1023)
1739
- # req.set_range 0, 1023
2172
+ # With argument `length`:
1740
2173
  #
1741
- def set_range: (Range[Integer] | Numeric r, ?Integer? e) -> Range[Integer]
1742
-
1743
- # <!--
1744
- # rdoc-file=lib/net/http/header.rb
1745
- # - range=(r, e = nil)
2174
+ # req = Net::HTTP::Get.new(uri)
2175
+ # req.set_range(100) # => 100
2176
+ # req['Range'] # => "bytes=0-99"
2177
+ #
2178
+ # With arguments `offset` and `length`:
2179
+ #
2180
+ # req.set_range(100, 100) # => 100...200
2181
+ # req['Range'] # => "bytes=100-199"
2182
+ #
2183
+ # With argument `range`:
2184
+ #
2185
+ # req.set_range(100..199) # => 100..199
2186
+ # req['Range'] # => "bytes=100-199"
2187
+ #
2188
+ # Net::HTTPHeader#range= is an alias for Net::HTTPHeader#set_range.
2189
+ #
2190
+ def set_range: (Range[Integer] | Numeric r, ?Integer? e) -> Range[Integer]
2191
+
2192
+ # <!--
2193
+ # rdoc-file=lib/net/http/header.rb
2194
+ # - range=(r, e = nil)
1746
2195
  # -->
1747
2196
  #
1748
2197
  alias range= set_range
@@ -1751,8 +2200,15 @@ module Net
1751
2200
  # rdoc-file=lib/net/http/header.rb
1752
2201
  # - content_length()
1753
2202
  # -->
1754
- # Returns an Integer object which represents the HTTP Content-Length: header
1755
- # field, or `nil` if that field was not provided.
2203
+ # Returns the value of field `'Content-Length'` as an integer, or `nil` if there
2204
+ # is no such field; see [Content-Length request
2205
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt
2206
+ # h-request-header):
2207
+ #
2208
+ # res = Net::HTTP.get_response(hostname, '/nosuch/1')
2209
+ # res.content_length # => 2
2210
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
2211
+ # res.content_length # => nil
1756
2212
  #
1757
2213
  def content_length: () -> (nil | Integer)
1758
2214
 
@@ -1760,6 +2216,21 @@ module Net
1760
2216
  # rdoc-file=lib/net/http/header.rb
1761
2217
  # - content_length=(len)
1762
2218
  # -->
2219
+ # Sets the value of field `'Content-Length'` to the given numeric; see
2220
+ # [Content-Length response
2221
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-lengt
2222
+ # h-response-header):
2223
+ #
2224
+ # _uri = uri.dup
2225
+ # hostname = _uri.hostname # => "jsonplaceholder.typicode.com"
2226
+ # _uri.path = '/posts' # => "/posts"
2227
+ # req = Net::HTTP::Post.new(_uri) # => #<Net::HTTP::Post POST>
2228
+ # req.body = '{"title": "foo","body": "bar","userId": 1}'
2229
+ # req.content_length = req.body.size # => 42
2230
+ # req.content_type = 'application/json'
2231
+ # res = Net::HTTP.start(hostname) do |http|
2232
+ # http.request(req)
2233
+ # end # => #<Net::HTTPCreated 201 Created readbody=true>
1763
2234
  #
1764
2235
  def content_length=: (Integer len) -> void
1765
2236
 
@@ -1767,9 +2238,14 @@ module Net
1767
2238
  # rdoc-file=lib/net/http/header.rb
1768
2239
  # - chunked?()
1769
2240
  # -->
1770
- # Returns "true" if the "transfer-encoding" header is present and set to
1771
- # "chunked". This is an HTTP/1.1 feature, allowing the content to be sent in
1772
- # "chunks" without at the outset stating the entire content length.
2241
+ # Returns `true` if field `'Transfer-Encoding'` exists and has value
2242
+ # `'chunked'`, `false` otherwise; see [Transfer-Encoding response
2243
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-enco
2244
+ # ding-response-header):
2245
+ #
2246
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
2247
+ # res['Transfer-Encoding'] # => "chunked"
2248
+ # res.chunked? # => true
1773
2249
  #
1774
2250
  def chunked?: () -> bool
1775
2251
 
@@ -1777,9 +2253,16 @@ module Net
1777
2253
  # rdoc-file=lib/net/http/header.rb
1778
2254
  # - content_range()
1779
2255
  # -->
1780
- # Returns a Range object which represents the value of the Content-Range: header
1781
- # field. For a partial entity body, this indicates where this fragment fits
1782
- # inside the full entity body, as range of byte offsets.
2256
+ # Returns a Range object representing the value of field `'Content-Range'`, or
2257
+ # `nil` if no such field exists; see [Content-Range response
2258
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range
2259
+ # -response-header):
2260
+ #
2261
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
2262
+ # res['Content-Range'] # => nil
2263
+ # res['Content-Range'] = 'bytes 0-499/1000'
2264
+ # res['Content-Range'] # => "bytes 0-499/1000"
2265
+ # res.content_range # => 0..499
1783
2266
  #
1784
2267
  def content_range: () -> (Range[Integer] | nil)
1785
2268
 
@@ -1787,7 +2270,16 @@ module Net
1787
2270
  # rdoc-file=lib/net/http/header.rb
1788
2271
  # - range_length()
1789
2272
  # -->
1790
- # The length of the range represented in Content-Range: header.
2273
+ # Returns the integer representing length of the value of field
2274
+ # `'Content-Range'`, or `nil` if no such field exists; see [Content-Range
2275
+ # response
2276
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range
2277
+ # -response-header):
2278
+ #
2279
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
2280
+ # res['Content-Range'] # => nil
2281
+ # res['Content-Range'] = 'bytes 0-499/1000'
2282
+ # res.range_length # => 500
1791
2283
  #
1792
2284
  def range_length: () -> (nil | Integer)
1793
2285
 
@@ -1795,8 +2287,15 @@ module Net
1795
2287
  # rdoc-file=lib/net/http/header.rb
1796
2288
  # - content_type()
1797
2289
  # -->
1798
- # Returns a content type string such as "text/html". This method returns nil if
1799
- # Content-Type: header field does not exist.
2290
+ # Returns the [media type](https://en.wikipedia.org/wiki/Media_type) from the
2291
+ # value of field `'Content-Type'`, or `nil` if no such field exists; see
2292
+ # [Content-Type response
2293
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-
2294
+ # response-header):
2295
+ #
2296
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
2297
+ # res['content-type'] # => "application/json; charset=utf-8"
2298
+ # res.content_type # => "application/json"
1800
2299
  #
1801
2300
  def content_type: () -> (nil | String)
1802
2301
 
@@ -1804,8 +2303,15 @@ module Net
1804
2303
  # rdoc-file=lib/net/http/header.rb
1805
2304
  # - main_type()
1806
2305
  # -->
1807
- # Returns a content type string such as "text". This method returns nil if
1808
- # Content-Type: header field does not exist.
2306
+ # Returns the leading ('type') part of the [media
2307
+ # type](https://en.wikipedia.org/wiki/Media_type) from the value of field
2308
+ # `'Content-Type'`, or `nil` if no such field exists; see [Content-Type response
2309
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-
2310
+ # response-header):
2311
+ #
2312
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
2313
+ # res['content-type'] # => "application/json; charset=utf-8"
2314
+ # res.main_type # => "application"
1809
2315
  #
1810
2316
  def main_type: () -> (nil | String)
1811
2317
 
@@ -1813,9 +2319,15 @@ module Net
1813
2319
  # rdoc-file=lib/net/http/header.rb
1814
2320
  # - sub_type()
1815
2321
  # -->
1816
- # Returns a content type string such as "html". This method returns nil if
1817
- # Content-Type: header field does not exist or sub-type is not given (e.g.
1818
- # "Content-Type: text").
2322
+ # Returns the trailing ('subtype') part of the [media
2323
+ # type](https://en.wikipedia.org/wiki/Media_type) from the value of field
2324
+ # `'Content-Type'`, or `nil` if no such field exists; see [Content-Type response
2325
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-
2326
+ # response-header):
2327
+ #
2328
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
2329
+ # res['content-type'] # => "application/json; charset=utf-8"
2330
+ # res.sub_type # => "json"
1819
2331
  #
1820
2332
  def sub_type: () -> (nil | String)
1821
2333
 
@@ -1823,9 +2335,14 @@ module Net
1823
2335
  # rdoc-file=lib/net/http/header.rb
1824
2336
  # - type_params()
1825
2337
  # -->
1826
- # Any parameters specified for the content type, returned as a Hash. For
1827
- # example, a header of Content-Type: text/html; charset=EUC-JP would result in
1828
- # type_params returning {'charset' => 'EUC-JP'}
2338
+ # Returns the trailing ('parameters') part of the value of field
2339
+ # `'Content-Type'`, or `nil` if no such field exists; see [Content-Type response
2340
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-
2341
+ # response-header):
2342
+ #
2343
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
2344
+ # res['content-type'] # => "application/json; charset=utf-8"
2345
+ # res.type_params # => {"charset"=>"utf-8"}
1829
2346
  #
1830
2347
  def type_params: () -> Hash[untyped, untyped]
1831
2348
 
@@ -1833,9 +2350,16 @@ module Net
1833
2350
  # rdoc-file=lib/net/http/header.rb
1834
2351
  # - set_content_type(type, params = {})
1835
2352
  # -->
1836
- # Sets the content type in an HTTP header. The `type` should be a full HTTP
1837
- # content type, e.g. "text/html". The `params` are an optional Hash of
1838
- # parameters to add after the content type, e.g. {'charset' => 'iso-8859-1'}
2353
+ # Sets the value of field `'Content-Type'`; returns the new value; see
2354
+ # [Content-Type request
2355
+ # header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-
2356
+ # request-header):
2357
+ #
2358
+ # req = Net::HTTP::Get.new(uri)
2359
+ # req.set_content_type('application/json') # => ["application/json"]
2360
+ #
2361
+ # Net::HTTPHeader#content_type= is an alias for
2362
+ # Net::HTTPHeader#set_content_type.
1839
2363
  #
1840
2364
  def set_content_type: (key `type`, ?Hash[untyped, untyped] params) -> void
1841
2365
 
@@ -1858,10 +2382,13 @@ module Net
1858
2382
  # application/x-www-form-urlencoded
1859
2383
  #
1860
2384
  # Example:
2385
+ #
1861
2386
  # http.form_data = {"q" => "ruby", "lang" => "en"}
1862
2387
  # http.form_data = {"q" => ["ruby", "perl"], "lang" => "en"}
1863
2388
  # http.set_form_data({"q" => "ruby", "lang" => "en"}, ';')
1864
2389
  #
2390
+ # Net::HTTPHeader#form_data= is an alias for Net::HTTPHeader#set_form_data.
2391
+ #
1865
2392
  def set_form_data: (Hash[untyped, untyped] params, ?String sep) -> void
1866
2393
 
1867
2394
  # <!--
@@ -1895,12 +2422,16 @@ module Net
1895
2422
  #
1896
2423
  # Each item of params should respond to `each` and yield 2-3 arguments, or an
1897
2424
  # array of 2-3 elements. The arguments yielded should be:
1898
- # * The name of the field.
1899
- # * The value of the field, it should be a String or a File or IO-like.
1900
- # * An options hash, supporting the following options, only
1901
- # used for file uploads:
1902
- # :filename :: The name of the file to use.
1903
- # :content_type :: The content type of the uploaded file.
2425
+ #
2426
+ # * The name of the field.
2427
+ # * The value of the field, it should be a String or a File or IO-like.
2428
+ # * An options hash, supporting the following options (used only for file
2429
+ # uploads); entries:
2430
+ #
2431
+ # * `:filename`: The name of the file to use.
2432
+ # * `:content_type`: The content type of the uploaded file.
2433
+ #
2434
+ #
1904
2435
  #
1905
2436
  # Each item is a file field or a normal field. If `value` is a File object or
1906
2437
  # the `opt` hash has a :filename key, the item is treated as a file field.
@@ -1910,6 +2441,7 @@ module Net
1910
2441
  # that the server supports HTTP/1.1 before using chunked encoding.
1911
2442
  #
1912
2443
  # Example:
2444
+ #
1913
2445
  # req.set_form([["q", "ruby"], ["lang", "en"]])
1914
2446
  #
1915
2447
  # req.set_form({"f"=>File.open('/path/to/filename')},
@@ -1971,9 +2503,32 @@ module Net
1971
2503
  end
1972
2504
 
1973
2505
  # <!-- rdoc-file=lib/net/http/request.rb -->
1974
- # HTTP request class. This class wraps together the request header and the
1975
- # request path. You cannot use this class directly. Instead, you should use one
1976
- # of its subclasses: Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Head.
2506
+ # This class is the base class for Net::HTTP request classes; it wraps together
2507
+ # the request path and the request headers.
2508
+ #
2509
+ # The class should not be used directly; instead you should use its subclasses.
2510
+ #
2511
+ # Subclasses for HTTP requests:
2512
+ #
2513
+ # * Net::HTTP::Get
2514
+ # * Net::HTTP::Head
2515
+ # * Net::HTTP::Post
2516
+ # * Net::HTTP::Put
2517
+ # * Net::HTTP::Delete
2518
+ # * Net::HTTP::Options
2519
+ # * Net::HTTP::Trace
2520
+ # * Net::HTTP::Patch
2521
+ #
2522
+ #
2523
+ # Subclasses for WebDAV requests:
2524
+ #
2525
+ # * Net::HTTP::Propfind
2526
+ # * Net::HTTP::Proppatch
2527
+ # * Net::HTTP::Mkcol
2528
+ # * Net::HTTP::Copy
2529
+ # * Net::HTTP::Move
2530
+ # * Net::HTTP::Lock
2531
+ # * Net::HTTP::Unlock
1977
2532
  #
1978
2533
  class HTTPRequest < HTTPGenericRequest
1979
2534
  # <!--
@@ -1991,8 +2546,34 @@ module Net
1991
2546
  end
1992
2547
 
1993
2548
  # <!-- rdoc-file=lib/net/http/requests.rb -->
1994
- # See Net::HTTPGenericRequest for attributes and methods. See Net::HTTP for
1995
- # usage examples.
2549
+ # Class for representing [HTTP method
2550
+ # GET](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#GE
2551
+ # T_method):
2552
+ #
2553
+ # require 'net/http'
2554
+ # uri = URI('http://example.com')
2555
+ # hostname = uri.hostname # => "example.com"
2556
+ # req = Net::HTTP::Get.new(uri) # => #<Net::HTTP::Get GET>
2557
+ # res = Net::HTTP.start(hostname) do |http|
2558
+ # http.request(req)
2559
+ # end
2560
+ #
2561
+ # Properties:
2562
+ #
2563
+ # * Request body: optional.
2564
+ # * Response body: yes.
2565
+ # * [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth
2566
+ # ods): yes.
2567
+ # * [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide
2568
+ # mpotent_methods): yes.
2569
+ # * [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach
2570
+ # eable_methods): yes.
2571
+ #
2572
+ #
2573
+ # Related:
2574
+ #
2575
+ # * Net::HTTP.get: sends `GET` request, returns response body.
2576
+ # * Net::HTTP#get: sends `GET` request, returns response object.
1996
2577
  #
1997
2578
  class HTTP::Get < HTTPRequest
1998
2579
  METHOD: String
@@ -2003,8 +2584,33 @@ module Net
2003
2584
  end
2004
2585
 
2005
2586
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2006
- # See Net::HTTPGenericRequest for attributes and methods. See Net::HTTP for
2007
- # usage examples.
2587
+ # Class for representing [HTTP method
2588
+ # HEAD](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#H
2589
+ # EAD_method):
2590
+ #
2591
+ # require 'net/http'
2592
+ # uri = URI('http://example.com')
2593
+ # hostname = uri.hostname # => "example.com"
2594
+ # req = Net::HTTP::Head.new(uri) # => #<Net::HTTP::Head HEAD>
2595
+ # res = Net::HTTP.start(hostname) do |http|
2596
+ # http.request(req)
2597
+ # end
2598
+ #
2599
+ # Properties:
2600
+ #
2601
+ # * Request body: optional.
2602
+ # * Response body: no.
2603
+ # * [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth
2604
+ # ods): yes.
2605
+ # * [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide
2606
+ # mpotent_methods): yes.
2607
+ # * [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach
2608
+ # eable_methods): yes.
2609
+ #
2610
+ #
2611
+ # Related:
2612
+ #
2613
+ # * Net::HTTP#head: sends `HEAD` request, returns response object.
2008
2614
  #
2009
2615
  class HTTP::Head < HTTPRequest
2010
2616
  METHOD: String
@@ -2015,8 +2621,37 @@ module Net
2015
2621
  end
2016
2622
 
2017
2623
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2018
- # See Net::HTTPGenericRequest for attributes and methods. See Net::HTTP for
2019
- # usage examples.
2624
+ # Class for representing [HTTP method
2625
+ # POST](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#P
2626
+ # OST_method):
2627
+ #
2628
+ # require 'net/http'
2629
+ # uri = URI('http://example.com')
2630
+ # hostname = uri.hostname # => "example.com"
2631
+ # uri.path = '/posts'
2632
+ # req = Net::HTTP::Post.new(uri) # => #<Net::HTTP::Post POST>
2633
+ # req.body = '{"title": "foo","body": "bar","userId": 1}'
2634
+ # req.content_type = 'application/json'
2635
+ # res = Net::HTTP.start(hostname) do |http|
2636
+ # http.request(req)
2637
+ # end
2638
+ #
2639
+ # Properties:
2640
+ #
2641
+ # * Request body: yes.
2642
+ # * Response body: yes.
2643
+ # * [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth
2644
+ # ods): no.
2645
+ # * [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide
2646
+ # mpotent_methods): no.
2647
+ # * [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach
2648
+ # eable_methods): yes.
2649
+ #
2650
+ #
2651
+ # Related:
2652
+ #
2653
+ # * Net::HTTP.post: sends `POST` request, returns response object.
2654
+ # * Net::HTTP#post: sends `POST` request, returns response object.
2020
2655
  #
2021
2656
  class HTTP::Post < HTTPRequest
2022
2657
  METHOD: String
@@ -2027,8 +2662,31 @@ module Net
2027
2662
  end
2028
2663
 
2029
2664
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2030
- # See Net::HTTPGenericRequest for attributes and methods. See Net::HTTP for
2031
- # usage examples.
2665
+ # Class for representing [HTTP method
2666
+ # PUT](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#PU
2667
+ # T_method):
2668
+ #
2669
+ # require 'net/http'
2670
+ # uri = URI('http://example.com')
2671
+ # hostname = uri.hostname # => "example.com"
2672
+ # uri.path = '/posts'
2673
+ # req = Net::HTTP::Put.new(uri) # => #<Net::HTTP::Put PUT>
2674
+ # req.body = '{"title": "foo","body": "bar","userId": 1}'
2675
+ # req.content_type = 'application/json'
2676
+ # res = Net::HTTP.start(hostname) do |http|
2677
+ # http.request(req)
2678
+ # end
2679
+ #
2680
+ # Properties:
2681
+ #
2682
+ # * Request body: yes.
2683
+ # * Response body: yes.
2684
+ # * [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth
2685
+ # ods): no.
2686
+ # * [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide
2687
+ # mpotent_methods): yes.
2688
+ # * [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach
2689
+ # eable_methods): no.
2032
2690
  #
2033
2691
  class HTTP::Put < HTTPRequest
2034
2692
  METHOD: String
@@ -2039,8 +2697,34 @@ module Net
2039
2697
  end
2040
2698
 
2041
2699
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2042
- # See Net::HTTPGenericRequest for attributes and methods. See Net::HTTP for
2043
- # usage examples.
2700
+ # Class for representing [HTTP method
2701
+ # DELETE](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol
2702
+ # #DELETE_method):
2703
+ #
2704
+ # require 'net/http'
2705
+ # uri = URI('http://example.com')
2706
+ # hostname = uri.hostname # => "example.com"
2707
+ # uri.path = '/posts/1'
2708
+ # req = Net::HTTP::Delete.new(uri) # => #<Net::HTTP::Delete DELETE>
2709
+ # res = Net::HTTP.start(hostname) do |http|
2710
+ # http.request(req)
2711
+ # end
2712
+ #
2713
+ # Properties:
2714
+ #
2715
+ # * Request body: optional.
2716
+ # * Response body: yes.
2717
+ # * [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth
2718
+ # ods): no.
2719
+ # * [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide
2720
+ # mpotent_methods): yes.
2721
+ # * [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach
2722
+ # eable_methods): no.
2723
+ #
2724
+ #
2725
+ # Related:
2726
+ #
2727
+ # * Net::HTTP#delete: sends `DELETE` request, returns response object.
2044
2728
  #
2045
2729
  class HTTP::Delete < HTTPRequest
2046
2730
  METHOD: String
@@ -2051,7 +2735,33 @@ module Net
2051
2735
  end
2052
2736
 
2053
2737
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2054
- # See Net::HTTPGenericRequest for attributes and methods.
2738
+ # Class for representing [HTTP method
2739
+ # OPTIONS](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protoco
2740
+ # l#OPTIONS_method):
2741
+ #
2742
+ # require 'net/http'
2743
+ # uri = URI('http://example.com')
2744
+ # hostname = uri.hostname # => "example.com"
2745
+ # req = Net::HTTP::Options.new(uri) # => #<Net::HTTP::Options OPTIONS>
2746
+ # res = Net::HTTP.start(hostname) do |http|
2747
+ # http.request(req)
2748
+ # end
2749
+ #
2750
+ # Properties:
2751
+ #
2752
+ # * Request body: optional.
2753
+ # * Response body: yes.
2754
+ # * [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth
2755
+ # ods): yes.
2756
+ # * [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide
2757
+ # mpotent_methods): yes.
2758
+ # * [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach
2759
+ # eable_methods): no.
2760
+ #
2761
+ #
2762
+ # Related:
2763
+ #
2764
+ # * Net::HTTP#options: sends `OPTIONS` request, returns response object.
2055
2765
  #
2056
2766
  class HTTP::Options < HTTPRequest
2057
2767
  METHOD: String
@@ -2062,7 +2772,33 @@ module Net
2062
2772
  end
2063
2773
 
2064
2774
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2065
- # See Net::HTTPGenericRequest for attributes and methods.
2775
+ # Class for representing [HTTP method
2776
+ # TRACE](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#
2777
+ # TRACE_method):
2778
+ #
2779
+ # require 'net/http'
2780
+ # uri = URI('http://example.com')
2781
+ # hostname = uri.hostname # => "example.com"
2782
+ # req = Net::HTTP::Trace.new(uri) # => #<Net::HTTP::Trace TRACE>
2783
+ # res = Net::HTTP.start(hostname) do |http|
2784
+ # http.request(req)
2785
+ # end
2786
+ #
2787
+ # Properties:
2788
+ #
2789
+ # * Request body: no.
2790
+ # * Response body: yes.
2791
+ # * [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth
2792
+ # ods): yes.
2793
+ # * [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide
2794
+ # mpotent_methods): yes.
2795
+ # * [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach
2796
+ # eable_methods): no.
2797
+ #
2798
+ #
2799
+ # Related:
2800
+ #
2801
+ # * Net::HTTP#trace: sends `TRACE` request, returns response object.
2066
2802
  #
2067
2803
  class HTTP::Trace < HTTPRequest
2068
2804
  METHOD: String
@@ -2073,7 +2809,36 @@ module Net
2073
2809
  end
2074
2810
 
2075
2811
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2076
- # See Net::HTTPGenericRequest for attributes and methods.
2812
+ # Class for representing [HTTP method
2813
+ # PATCH](https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#
2814
+ # PATCH_method):
2815
+ #
2816
+ # require 'net/http'
2817
+ # uri = URI('http://example.com')
2818
+ # hostname = uri.hostname # => "example.com"
2819
+ # uri.path = '/posts'
2820
+ # req = Net::HTTP::Patch.new(uri) # => #<Net::HTTP::Patch PATCH>
2821
+ # req.body = '{"title": "foo","body": "bar","userId": 1}'
2822
+ # req.content_type = 'application/json'
2823
+ # res = Net::HTTP.start(hostname) do |http|
2824
+ # http.request(req)
2825
+ # end
2826
+ #
2827
+ # Properties:
2828
+ #
2829
+ # * Request body: yes.
2830
+ # * Response body: yes.
2831
+ # * [Safe](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_meth
2832
+ # ods): no.
2833
+ # * [Idempotent](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Ide
2834
+ # mpotent_methods): no.
2835
+ # * [Cacheable](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cach
2836
+ # eable_methods): no.
2837
+ #
2838
+ #
2839
+ # Related:
2840
+ #
2841
+ # * Net::HTTP#patch: sends `PATCH` request, returns response object.
2077
2842
  #
2078
2843
  class HTTP::Patch < HTTPRequest
2079
2844
  METHOD: String
@@ -2084,7 +2849,20 @@ module Net
2084
2849
  end
2085
2850
 
2086
2851
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2087
- # See Net::HTTPGenericRequest for attributes and methods.
2852
+ # Class for representing [WebDAV method
2853
+ # PROPFIND](http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND):
2854
+ #
2855
+ # require 'net/http'
2856
+ # uri = URI('http://example.com')
2857
+ # hostname = uri.hostname # => "example.com"
2858
+ # req = Net::HTTP::Propfind.new(uri) # => #<Net::HTTP::Propfind PROPFIND>
2859
+ # res = Net::HTTP.start(hostname) do |http|
2860
+ # http.request(req)
2861
+ # end
2862
+ #
2863
+ # Related:
2864
+ #
2865
+ # * Net::HTTP#propfind: sends `PROPFIND` request, returns response object.
2088
2866
  #
2089
2867
  class HTTP::Propfind < HTTPRequest
2090
2868
  METHOD: String
@@ -2095,7 +2873,20 @@ module Net
2095
2873
  end
2096
2874
 
2097
2875
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2098
- # See Net::HTTPGenericRequest for attributes and methods.
2876
+ # Class for representing [WebDAV method
2877
+ # PROPPATCH](http://www.webdav.org/specs/rfc4918.html#METHOD_PROPPATCH):
2878
+ #
2879
+ # require 'net/http'
2880
+ # uri = URI('http://example.com')
2881
+ # hostname = uri.hostname # => "example.com"
2882
+ # req = Net::HTTP::Proppatch.new(uri) # => #<Net::HTTP::Proppatch PROPPATCH>
2883
+ # res = Net::HTTP.start(hostname) do |http|
2884
+ # http.request(req)
2885
+ # end
2886
+ #
2887
+ # Related:
2888
+ #
2889
+ # * Net::HTTP#proppatch: sends `PROPPATCH` request, returns response object.
2099
2890
  #
2100
2891
  class HTTP::Proppatch < HTTPRequest
2101
2892
  METHOD: String
@@ -2106,7 +2897,20 @@ module Net
2106
2897
  end
2107
2898
 
2108
2899
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2109
- # See Net::HTTPGenericRequest for attributes and methods.
2900
+ # Class for representing [WebDAV method
2901
+ # MKCOL](http://www.webdav.org/specs/rfc4918.html#METHOD_MKCOL):
2902
+ #
2903
+ # require 'net/http'
2904
+ # uri = URI('http://example.com')
2905
+ # hostname = uri.hostname # => "example.com"
2906
+ # req = Net::HTTP::Mkcol.new(uri) # => #<Net::HTTP::Mkcol MKCOL>
2907
+ # res = Net::HTTP.start(hostname) do |http|
2908
+ # http.request(req)
2909
+ # end
2910
+ #
2911
+ # Related:
2912
+ #
2913
+ # * Net::HTTP#mkcol: sends `MKCOL` request, returns response object.
2110
2914
  #
2111
2915
  class HTTP::Mkcol < HTTPRequest
2112
2916
  METHOD: String
@@ -2117,7 +2921,20 @@ module Net
2117
2921
  end
2118
2922
 
2119
2923
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2120
- # See Net::HTTPGenericRequest for attributes and methods.
2924
+ # Class for representing [WebDAV method
2925
+ # COPY](http://www.webdav.org/specs/rfc4918.html#METHOD_COPY):
2926
+ #
2927
+ # require 'net/http'
2928
+ # uri = URI('http://example.com')
2929
+ # hostname = uri.hostname # => "example.com"
2930
+ # req = Net::HTTP::Copy.new(uri) # => #<Net::HTTP::Copy COPY>
2931
+ # res = Net::HTTP.start(hostname) do |http|
2932
+ # http.request(req)
2933
+ # end
2934
+ #
2935
+ # Related:
2936
+ #
2937
+ # * Net::HTTP#copy: sends `COPY` request, returns response object.
2121
2938
  #
2122
2939
  class HTTP::Copy < HTTPRequest
2123
2940
  METHOD: String
@@ -2128,7 +2945,20 @@ module Net
2128
2945
  end
2129
2946
 
2130
2947
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2131
- # See Net::HTTPGenericRequest for attributes and methods.
2948
+ # Class for representing [WebDAV method
2949
+ # MOVE](http://www.webdav.org/specs/rfc4918.html#METHOD_MOVE):
2950
+ #
2951
+ # require 'net/http'
2952
+ # uri = URI('http://example.com')
2953
+ # hostname = uri.hostname # => "example.com"
2954
+ # req = Net::HTTP::Move.new(uri) # => #<Net::HTTP::Move MOVE>
2955
+ # res = Net::HTTP.start(hostname) do |http|
2956
+ # http.request(req)
2957
+ # end
2958
+ #
2959
+ # Related:
2960
+ #
2961
+ # * Net::HTTP#move: sends `MOVE` request, returns response object.
2132
2962
  #
2133
2963
  class HTTP::Move < HTTPRequest
2134
2964
  METHOD: String
@@ -2139,7 +2969,20 @@ module Net
2139
2969
  end
2140
2970
 
2141
2971
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2142
- # See Net::HTTPGenericRequest for attributes and methods.
2972
+ # Class for representing [WebDAV method
2973
+ # LOCK](http://www.webdav.org/specs/rfc4918.html#METHOD_LOCK):
2974
+ #
2975
+ # require 'net/http'
2976
+ # uri = URI('http://example.com')
2977
+ # hostname = uri.hostname # => "example.com"
2978
+ # req = Net::HTTP::Lock.new(uri) # => #<Net::HTTP::Lock LOCK>
2979
+ # res = Net::HTTP.start(hostname) do |http|
2980
+ # http.request(req)
2981
+ # end
2982
+ #
2983
+ # Related:
2984
+ #
2985
+ # * Net::HTTP#lock: sends `LOCK` request, returns response object.
2143
2986
  #
2144
2987
  class HTTP::Lock < HTTPRequest
2145
2988
  METHOD: String
@@ -2150,7 +2993,20 @@ module Net
2150
2993
  end
2151
2994
 
2152
2995
  # <!-- rdoc-file=lib/net/http/requests.rb -->
2153
- # See Net::HTTPGenericRequest for attributes and methods.
2996
+ # Class for representing [WebDAV method
2997
+ # UNLOCK](http://www.webdav.org/specs/rfc4918.html#METHOD_UNLOCK):
2998
+ #
2999
+ # require 'net/http'
3000
+ # uri = URI('http://example.com')
3001
+ # hostname = uri.hostname # => "example.com"
3002
+ # req = Net::HTTP::Unlock.new(uri) # => #<Net::HTTP::Unlock UNLOCK>
3003
+ # res = Net::HTTP.start(hostname) do |http|
3004
+ # http.request(req)
3005
+ # end
3006
+ #
3007
+ # Related:
3008
+ #
3009
+ # * Net::HTTP#unlock: sends `UNLOCK` request, returns response object.
2154
3010
  #
2155
3011
  class HTTP::Unlock < HTTPRequest
2156
3012
  METHOD: String
@@ -2161,21 +3017,175 @@ module Net
2161
3017
  end
2162
3018
 
2163
3019
  # <!-- rdoc-file=lib/net/http/response.rb -->
2164
- # HTTP response class.
3020
+ # This class is the base class for Net::HTTP request classes.
3021
+ #
3022
+ # ## About the Examples
3023
+ #
3024
+ # Examples here assume that `net/http` has been required (which also requires
3025
+ # `uri`):
3026
+ #
3027
+ # require 'net/http'
3028
+ #
3029
+ # Many code examples here use these example websites:
3030
+ #
3031
+ # * https://jsonplaceholder.typicode.com.
3032
+ # * http://example.com.
3033
+ #
3034
+ #
3035
+ # Some examples also assume these variables:
3036
+ #
3037
+ # uri = URI('https://jsonplaceholder.typicode.com')
3038
+ # uri.freeze # Examples may not modify.
3039
+ # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
3040
+ # port = uri.port # => 443
3041
+ #
3042
+ # So that example requests may be written as:
3043
+ #
3044
+ # Net::HTTP.get(uri)
3045
+ # Net::HTTP.get(hostname, '/index.html')
3046
+ # Net::HTTP.start(hostname) do |http|
3047
+ # http.get('/todos/1')
3048
+ # http.get('/todos/2')
3049
+ # end
3050
+ #
3051
+ # An example that needs a modified URI first duplicates `uri`, then modifies the
3052
+ # duplicate:
3053
+ #
3054
+ # _uri = uri.dup
3055
+ # _uri.path = '/todos/1'
3056
+ #
3057
+ # ## Returned Responses
3058
+ #
3059
+ # Method Net::HTTP.get_response returns an instance of one of the subclasses of
3060
+ # Net::HTTPResponse:
3061
+ #
3062
+ # Net::HTTP.get_response(uri)
3063
+ # # => #<Net::HTTPOK 200 OK readbody=true>
3064
+ # Net::HTTP.get_response(hostname, '/nosuch')
3065
+ # # => #<Net::HTTPNotFound 404 Not Found readbody=true>
3066
+ #
3067
+ # As does method Net::HTTP#request:
3068
+ #
3069
+ # req = Net::HTTP::Get.new(uri)
3070
+ # Net::HTTP.start(hostname) do |http|
3071
+ # http.request(req)
3072
+ # end # => #<Net::HTTPOK 200 OK readbody=true>
3073
+ #
3074
+ # Class Net::HTTPResponse includes module Net::HTTPHeader, which provides access
3075
+ # to response header values via (among others):
3076
+ #
3077
+ # * Hash-like method `[]`.
3078
+ # * Specific reader methods, such as `content_type`.
3079
+ #
3080
+ #
3081
+ # Examples:
3082
+ #
3083
+ # res = Net::HTTP.get_response(uri) # => #<Net::HTTPOK 200 OK readbody=true>
3084
+ # res['Content-Type'] # => "text/html; charset=UTF-8"
3085
+ # res.content_type # => "text/html"
2165
3086
  #
2166
- # This class wraps together the response header and the response body (the
2167
- # entity requested).
3087
+ # ## Response Subclasses
2168
3088
  #
2169
- # It mixes in the HTTPHeader module, which provides access to response header
2170
- # values both via hash-like methods and via individual readers.
3089
+ # Class Net::HTTPResponse has a subclass for each [HTTP status
3090
+ # code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes). You can look
3091
+ # up the response class for a given code:
2171
3092
  #
2172
- # Note that each possible HTTP response code defines its own HTTPResponse
2173
- # subclass. All classes are defined under the Net module. Indentation indicates
2174
- # inheritance. For a list of the classes see Net::HTTP.
3093
+ # Net::HTTPResponse::CODE_TO_OBJ['200'] # => Net::HTTPOK
3094
+ # Net::HTTPResponse::CODE_TO_OBJ['400'] # => Net::HTTPBadRequest
3095
+ # Net::HTTPResponse::CODE_TO_OBJ['404'] # => Net::HTTPNotFound
2175
3096
  #
2176
- # Correspondence `HTTP code => class` is stored in CODE_TO_OBJ constant:
3097
+ # And you can retrieve the status code for a response object:
2177
3098
  #
2178
- # Net::HTTPResponse::CODE_TO_OBJ['404'] #=> Net::HTTPNotFound
3099
+ # Net::HTTP.get_response(uri).code # => "200"
3100
+ # Net::HTTP.get_response(hostname, '/nosuch').code # => "404"
3101
+ #
3102
+ # The response subclasses (indentation shows class hierarchy):
3103
+ #
3104
+ # * Net::HTTPUnknownResponse (for unhandled HTTP extensions).
3105
+ #
3106
+ # * Net::HTTPInformation:
3107
+ #
3108
+ # * Net::HTTPContinue (100)
3109
+ # * Net::HTTPSwitchProtocol (101)
3110
+ # * Net::HTTPProcessing (102)
3111
+ # * Net::HTTPEarlyHints (103)
3112
+ #
3113
+ #
3114
+ # * Net::HTTPSuccess:
3115
+ #
3116
+ # * Net::HTTPOK (200)
3117
+ # * Net::HTTPCreated (201)
3118
+ # * Net::HTTPAccepted (202)
3119
+ # * Net::HTTPNonAuthoritativeInformation (203)
3120
+ # * Net::HTTPNoContent (204)
3121
+ # * Net::HTTPResetContent (205)
3122
+ # * Net::HTTPPartialContent (206)
3123
+ # * Net::HTTPMultiStatus (207)
3124
+ # * Net::HTTPAlreadyReported (208)
3125
+ # * Net::HTTPIMUsed (226)
3126
+ #
3127
+ #
3128
+ # * Net::HTTPRedirection:
3129
+ #
3130
+ # * Net::HTTPMultipleChoices (300)
3131
+ # * Net::HTTPMovedPermanently (301)
3132
+ # * Net::HTTPFound (302)
3133
+ # * Net::HTTPSeeOther (303)
3134
+ # * Net::HTTPNotModified (304)
3135
+ # * Net::HTTPUseProxy (305)
3136
+ # * Net::HTTPTemporaryRedirect (307)
3137
+ # * Net::HTTPPermanentRedirect (308)
3138
+ #
3139
+ #
3140
+ # * Net::HTTPClientError:
3141
+ #
3142
+ # * Net::HTTPBadRequest (400)
3143
+ # * Net::HTTPUnauthorized (401)
3144
+ # * Net::HTTPPaymentRequired (402)
3145
+ # * Net::HTTPForbidden (403)
3146
+ # * Net::HTTPNotFound (404)
3147
+ # * Net::HTTPMethodNotAllowed (405)
3148
+ # * Net::HTTPNotAcceptable (406)
3149
+ # * Net::HTTPProxyAuthenticationRequired (407)
3150
+ # * Net::HTTPRequestTimeOut (408)
3151
+ # * Net::HTTPConflict (409)
3152
+ # * Net::HTTPGone (410)
3153
+ # * Net::HTTPLengthRequired (411)
3154
+ # * Net::HTTPPreconditionFailed (412)
3155
+ # * Net::HTTPRequestEntityTooLarge (413)
3156
+ # * Net::HTTPRequestURITooLong (414)
3157
+ # * Net::HTTPUnsupportedMediaType (415)
3158
+ # * Net::HTTPRequestedRangeNotSatisfiable (416)
3159
+ # * Net::HTTPExpectationFailed (417)
3160
+ # * Net::HTTPMisdirectedRequest (421)
3161
+ # * Net::HTTPUnprocessableEntity (422)
3162
+ # * Net::HTTPLocked (423)
3163
+ # * Net::HTTPFailedDependency (424)
3164
+ # * Net::HTTPUpgradeRequired (426)
3165
+ # * Net::HTTPPreconditionRequired (428)
3166
+ # * Net::HTTPTooManyRequests (429)
3167
+ # * Net::HTTPRequestHeaderFieldsTooLarge (431)
3168
+ # * Net::HTTPUnavailableForLegalReasons (451)
3169
+ #
3170
+ #
3171
+ # * Net::HTTPServerError:
3172
+ #
3173
+ # * Net::HTTPInternalServerError (500)
3174
+ # * Net::HTTPNotImplemented (501)
3175
+ # * Net::HTTPBadGateway (502)
3176
+ # * Net::HTTPServiceUnavailable (503)
3177
+ # * Net::HTTPGatewayTimeOut (504)
3178
+ # * Net::HTTPVersionNotSupported (505)
3179
+ # * Net::HTTPVariantAlsoNegotiates (506)
3180
+ # * Net::HTTPInsufficientStorage (507)
3181
+ # * Net::HTTPLoopDetected (508)
3182
+ # * Net::HTTPNotExtended (510)
3183
+ # * Net::HTTPNetworkAuthenticationRequired (511)
3184
+ #
3185
+ #
3186
+ #
3187
+ # There is also the Net::HTTPBadResponse exception which is raised when there is
3188
+ # a protocol error.
2179
3189
  #
2180
3190
  class HTTPResponse
2181
3191
  # <!--
@@ -2330,294 +3340,961 @@ module Net
2330
3340
  EXCEPTION_TYPE: Net::HTTPError
2331
3341
  end
2332
3342
 
3343
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3344
+ # Parent class for informational (1xx) HTTP response classes.
3345
+ #
3346
+ # An informational response indicates that the request was received and
3347
+ # understood.
3348
+ #
3349
+ # References:
3350
+ #
3351
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.1xx).
3352
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_in
3353
+ # formational_response).
3354
+ #
2333
3355
  class HTTPInformation < HTTPResponse
2334
3356
  HAS_BODY: bool
2335
3357
 
2336
3358
  EXCEPTION_TYPE: Net::HTTPError
2337
3359
  end
2338
3360
 
3361
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3362
+ # Parent class for success (2xx) HTTP response classes.
3363
+ #
3364
+ # A success response indicates the action requested by the client was received,
3365
+ # understood, and accepted.
3366
+ #
3367
+ # References:
3368
+ #
3369
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.2xx).
3370
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_su
3371
+ # ccess).
3372
+ #
2339
3373
  class HTTPSuccess < HTTPResponse
2340
3374
  HAS_BODY: bool
2341
3375
 
2342
3376
  EXCEPTION_TYPE: Net::HTTPError
2343
3377
  end
2344
3378
 
3379
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3380
+ # Parent class for redirection (3xx) HTTP response classes.
3381
+ #
3382
+ # A redirection response indicates the client must take additional action to
3383
+ # complete the request.
3384
+ #
3385
+ # References:
3386
+ #
3387
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.3xx).
3388
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_re
3389
+ # direction).
3390
+ #
2345
3391
  class HTTPRedirection < HTTPResponse
2346
3392
  HAS_BODY: bool
2347
3393
 
2348
3394
  EXCEPTION_TYPE: Net::HTTPRetriableError
2349
3395
  end
2350
3396
 
3397
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3398
+ # Parent class for client error (4xx) HTTP response classes.
3399
+ #
3400
+ # A client error response indicates that the client may have caused an error.
3401
+ #
3402
+ # References:
3403
+ #
3404
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.4xx).
3405
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_cl
3406
+ # ient_errors).
3407
+ #
2351
3408
  class HTTPClientError < HTTPResponse
2352
3409
  HAS_BODY: bool
2353
3410
 
2354
3411
  EXCEPTION_TYPE: untyped
2355
3412
  end
2356
3413
 
3414
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3415
+ # Parent class for server error (5xx) HTTP response classes.
3416
+ #
3417
+ # A server error response indicates that the server failed to fulfill a request.
3418
+ #
3419
+ # References:
3420
+ #
3421
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#status.5xx).
3422
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_se
3423
+ # rver_errors).
3424
+ #
2357
3425
  class HTTPServerError < HTTPResponse
2358
3426
  HAS_BODY: bool
2359
3427
 
2360
3428
  EXCEPTION_TYPE: Net::HTTPFatalError
2361
3429
  end
2362
3430
 
3431
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3432
+ # Response class for `Continue` responses (status code 100).
3433
+ #
3434
+ # A `Continue` response indicates that the server has received the request
3435
+ # headers.
3436
+ #
3437
+ # References:
3438
+ #
3439
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100).
3440
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-100-continue).
3441
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#100).
3442
+ #
2363
3443
  class HTTPContinue < HTTPInformation
2364
3444
  HAS_BODY: bool
2365
3445
  end
2366
3446
 
3447
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3448
+ # Response class for `Switching Protocol` responses (status code 101).
3449
+ #
3450
+ # The <tt>Switching Protocol<tt> response indicates that the server has received
3451
+ # a request to switch protocols, and has agreed to do so.
3452
+ #
3453
+ # References:
3454
+ #
3455
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/101).
3456
+ # * [RFC
3457
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-101-switching-proto
3458
+ # cols).
3459
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#101).
3460
+ #
2367
3461
  class HTTPSwitchProtocol < HTTPInformation
2368
3462
  HAS_BODY: bool
2369
3463
  end
2370
3464
 
3465
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3466
+ # Response class for `Processing` responses (status code 102).
3467
+ #
3468
+ # The `Processing` response indicates that the server has received and is
3469
+ # processing the request, but no response is available yet.
3470
+ #
3471
+ # References:
3472
+ #
3473
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#102).
3474
+ #
2371
3475
  class HTTPProcessing < HTTPInformation
2372
3476
  HAS_BODY: bool
2373
3477
  end
2374
3478
 
3479
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3480
+ # Response class for `Early Hints` responses (status code 103).
3481
+ #
3482
+ # The `Early Hints` indicates that the server has received and is processing the
3483
+ # request, and contains certain headers; the final response is not available
3484
+ # yet.
3485
+ #
3486
+ # References:
3487
+ #
3488
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103).
3489
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#103).
3490
+ #
2375
3491
  class HTTPEarlyHints < HTTPInformation
2376
3492
  HAS_BODY: bool
2377
3493
  end
2378
3494
 
3495
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3496
+ # Response class for `OK` responses (status code 200).
3497
+ #
3498
+ # The `OK` response indicates that the server has received a request and has
3499
+ # responded successfully. See [200
3500
+ # OK](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200).
3501
+ #
2379
3502
  class HTTPOK < HTTPSuccess
2380
3503
  HAS_BODY: bool
2381
3504
  end
2382
3505
 
3506
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3507
+ # Response class for `Created` responses (status code 201).
3508
+ #
3509
+ # The `Created` response indicates that the server has received and has
3510
+ # fulfilled a request to create a new resource. See [201
3511
+ # Created](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#201).
3512
+ #
2383
3513
  class HTTPCreated < HTTPSuccess
2384
3514
  HAS_BODY: bool
2385
3515
  end
2386
3516
 
3517
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3518
+ # Response class for `Accepted` responses (status code 202).
3519
+ #
3520
+ # The `Accepted` response indicates that the server has received and is
3521
+ # processing a request, but the processing has not yet been completed. See [202
3522
+ # Accepted](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#202).
3523
+ #
2387
3524
  class HTTPAccepted < HTTPSuccess
2388
3525
  HAS_BODY: bool
2389
3526
  end
2390
3527
 
3528
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3529
+ # Response class for `Non-Authoritative Information` responses (status code
3530
+ # 203).
3531
+ #
3532
+ # The `Non-Authoritative Information` response indicates that the server is a
3533
+ # transforming proxy (such as a Web accelerator) that received a 200 OK response
3534
+ # from its origin, and is returning a modified version of the origin's response.
3535
+ # See [203 Non-Authoritative
3536
+ # Information](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#203).
3537
+ #
2391
3538
  class HTTPNonAuthoritativeInformation < HTTPSuccess
2392
3539
  HAS_BODY: bool
2393
3540
  end
2394
3541
 
3542
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3543
+ # Response class for `No Content` responses (status code 204).
3544
+ #
3545
+ # The `No Content` response indicates that the server successfully processed the
3546
+ # request, and is not returning any content. See [204 No
3547
+ # Content](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204).
3548
+ #
2395
3549
  class HTTPNoContent < HTTPSuccess
2396
3550
  HAS_BODY: bool
2397
3551
  end
2398
3552
 
3553
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3554
+ # Response class for `Reset Content` responses (status code 205).
3555
+ #
3556
+ # The `Reset Content` response indicates that the server successfully processed
3557
+ # the request, asks that the client reset its document view, and is not
3558
+ # returning any content. See [205 Reset
3559
+ # Content](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#205).
3560
+ #
2399
3561
  class HTTPResetContent < HTTPSuccess
2400
3562
  HAS_BODY: bool
2401
3563
  end
2402
3564
 
3565
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3566
+ # Response class for `Partial Content` responses (status code 206).
3567
+ #
3568
+ # The `Partial Content` response indicates that the server is delivering only
3569
+ # part of the resource (byte serving) due to a Range header in the request. See
3570
+ # [206 Partial
3571
+ # Content](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#206).
3572
+ #
2403
3573
  class HTTPPartialContent < HTTPSuccess
2404
3574
  HAS_BODY: bool
2405
3575
  end
2406
3576
 
3577
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3578
+ # Response class for `Multi-Status (WebDAV)` responses (status code 207).
3579
+ #
3580
+ # The `Multi-Status (WebDAV)` response indicates that the server has received
3581
+ # the request, and that the message body can contain a number of separate
3582
+ # response codes. See [207 Multi-Status
3583
+ # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#207).
3584
+ #
2407
3585
  class HTTPMultiStatus < HTTPSuccess
2408
3586
  HAS_BODY: bool
2409
3587
  end
2410
3588
 
3589
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3590
+ # Response class for `Already Reported (WebDAV)` responses (status code 208).
3591
+ #
3592
+ # The `Already Reported (WebDAV)` response indicates that the server has
3593
+ # received the request, and that the members of a DAV binding have already been
3594
+ # enumerated in a preceding part of the (multi-status) response, and are not
3595
+ # being included again. See [208 Already Reported
3596
+ # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208).
3597
+ #
2411
3598
  class HTTPAlreadyReported < HTTPSuccess
2412
3599
  HAS_BODY: bool
2413
3600
  end
2414
3601
 
3602
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3603
+ # Response class for `IM Used` responses (status code 226).
3604
+ #
3605
+ # The `IM Used` response indicates that the server has fulfilled a request for
3606
+ # the resource, and the response is a representation of the result of one or
3607
+ # more instance-manipulations applied to the current instance. See [226 IM
3608
+ # Used](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#226).
3609
+ #
2415
3610
  class HTTPIMUsed < HTTPSuccess
2416
3611
  HAS_BODY: bool
2417
3612
  end
2418
3613
 
3614
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3615
+ # Response class for `Multiple Choices` responses (status code 300).
3616
+ #
3617
+ # The `Multiple Choices` response indicates that the server offers multiple
3618
+ # options for the resource from which the client may choose. See [300 Multiple
3619
+ # Choices](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300).
3620
+ #
2419
3621
  class HTTPMultipleChoices < HTTPRedirection
2420
3622
  HAS_BODY: bool
2421
3623
  end
2422
3624
 
3625
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3626
+ # Response class for `Multiple Choices` responses (status code 300).
3627
+ #
3628
+ # The `Multiple Choices` response indicates that the server offers multiple
3629
+ # options for the resource from which the client may choose. See [300 Multiple
3630
+ # Choices](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300).
3631
+ #
2423
3632
  HTTPMultipleChoice: HTTPMultipleChoices
2424
3633
 
3634
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3635
+ # Response class for `Moved Permanently` responses (status code 301).
3636
+ #
3637
+ # The `Moved Permanently` response indicates that links or records returning
3638
+ # this response should be updated to use the given URL. See [301 Moved
3639
+ # Permanently](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#301).
3640
+ #
2425
3641
  class HTTPMovedPermanently < HTTPRedirection
2426
3642
  HAS_BODY: bool
2427
3643
  end
2428
3644
 
3645
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3646
+ # Response class for `Found` responses (status code 302).
3647
+ #
3648
+ # The `Found` response indicates that the client should look at (browse to)
3649
+ # another URL. See [302
3650
+ # Found](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#302).
3651
+ #
2429
3652
  class HTTPFound < HTTPRedirection
2430
3653
  HAS_BODY: bool
2431
3654
  end
2432
3655
 
3656
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3657
+ # Response class for `See Other` responses (status code 303).
3658
+ #
3659
+ # The response to the request can be found under another URI using the GET
3660
+ # method. See [303 See
3661
+ # Other](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#303).
3662
+ #
2433
3663
  class HTTPSeeOther < HTTPRedirection
2434
3664
  HAS_BODY: bool
2435
3665
  end
2436
3666
 
3667
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3668
+ # Response class for `Not Modified` responses (status code 304).
3669
+ #
3670
+ # Indicates that the resource has not been modified since the version specified
3671
+ # by the request headers. See [304 Not
3672
+ # Modified](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#304).
3673
+ #
2437
3674
  class HTTPNotModified < HTTPRedirection
2438
3675
  HAS_BODY: bool
2439
3676
  end
2440
3677
 
3678
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3679
+ # Response class for `Use Proxy` responses (status code 305).
3680
+ #
3681
+ # The requested resource is available only through a proxy, whose address is
3682
+ # provided in the response. See [305 Use
3683
+ # Proxy](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#305).
3684
+ #
2441
3685
  class HTTPUseProxy < HTTPRedirection
2442
3686
  HAS_BODY: bool
2443
3687
  end
2444
3688
 
3689
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3690
+ # Response class for `Temporary Redirect` responses (status code 307).
3691
+ #
3692
+ # The request should be repeated with another URI; however, future requests
3693
+ # should still use the original URI. See [307 Temporary
3694
+ # Redirect](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#307).
3695
+ #
2445
3696
  class HTTPTemporaryRedirect < HTTPRedirection
2446
3697
  HAS_BODY: bool
2447
3698
  end
2448
3699
 
3700
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3701
+ # Response class for `Permanent Redirect` responses (status code 308).
3702
+ #
3703
+ # This and all future requests should be directed to the given URI. See [308
3704
+ # Permanent
3705
+ # Redirect](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#308).
3706
+ #
2449
3707
  class HTTPPermanentRedirect < HTTPRedirection
2450
3708
  HAS_BODY: bool
2451
3709
  end
2452
3710
 
3711
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3712
+ # Response class for `Bad Request` responses (status code 400).
3713
+ #
3714
+ # The server cannot or will not process the request due to an apparent client
3715
+ # error. See [400 Bad
3716
+ # Request](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#400).
3717
+ #
2453
3718
  class HTTPBadRequest < HTTPClientError
2454
3719
  HAS_BODY: bool
2455
3720
  end
2456
3721
 
3722
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3723
+ # Response class for `Unauthorized` responses (status code 401).
3724
+ #
3725
+ # Authentication is required, but either was not provided or failed. See [401
3726
+ # Unauthorized](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#401).
3727
+ #
2457
3728
  class HTTPUnauthorized < HTTPClientError
2458
3729
  HAS_BODY: bool
2459
3730
  end
2460
3731
 
3732
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3733
+ # Response class for `Payment Required` responses (status code 402).
3734
+ #
3735
+ # Reserved for future use. See [402 Payment
3736
+ # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#402).
3737
+ #
2461
3738
  class HTTPPaymentRequired < HTTPClientError
2462
3739
  HAS_BODY: bool
2463
3740
  end
2464
3741
 
3742
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3743
+ # Response class for `Forbidden` responses (status code 403).
3744
+ #
3745
+ # The request contained valid data and was understood by the server, but the
3746
+ # server is refusing action. See [403
3747
+ # Forbidden](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#403).
3748
+ #
2465
3749
  class HTTPForbidden < HTTPClientError
2466
3750
  HAS_BODY: bool
2467
3751
  end
2468
3752
 
3753
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3754
+ # Response class for `Not Found` responses (status code 404).
3755
+ #
3756
+ # The requested resource could not be found but may be available in the future.
3757
+ # See [404 Not
3758
+ # Found](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404).
3759
+ #
2469
3760
  class HTTPNotFound < HTTPClientError
2470
3761
  HAS_BODY: bool
2471
3762
  end
2472
3763
 
3764
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3765
+ # Response class for `Method Not Allowed` responses (status code 405).
3766
+ #
3767
+ # The request method is not supported for the requested resource. See [405
3768
+ # Method Not
3769
+ # Allowed](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405).
3770
+ #
2473
3771
  class HTTPMethodNotAllowed < HTTPClientError
2474
3772
  HAS_BODY: bool
2475
3773
  end
2476
3774
 
3775
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3776
+ # Response class for `Not Acceptable` responses (status code 406).
3777
+ #
3778
+ # The requested resource is capable of generating only content that not
3779
+ # acceptable according to the Accept headers sent in the request. See [406 Not
3780
+ # Acceptable](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#406).
3781
+ #
2477
3782
  class HTTPNotAcceptable < HTTPClientError
2478
3783
  HAS_BODY: bool
2479
3784
  end
2480
3785
 
3786
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3787
+ # Response class for `Proxy Authentication Required` responses (status code
3788
+ # 407).
3789
+ #
3790
+ # The client must first authenticate itself with the proxy. See [407 Proxy
3791
+ # Authentication
3792
+ # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#407).
3793
+ #
2481
3794
  class HTTPProxyAuthenticationRequired < HTTPClientError
2482
3795
  HAS_BODY: bool
2483
3796
  end
2484
3797
 
3798
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3799
+ # Response class for `Request Timeout` responses (status code 408).
3800
+ #
3801
+ # The server timed out waiting for the request. See [408 Request
3802
+ # Timeout](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#408).
3803
+ #
2485
3804
  class HTTPRequestTimeout < HTTPClientError
2486
3805
  HAS_BODY: bool
2487
3806
  end
2488
3807
 
3808
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3809
+ # Response class for `Conflict` responses (status code 409).
3810
+ #
3811
+ # The request could not be processed because of conflict in the current state of
3812
+ # the resource. See [409
3813
+ # Conflict](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#409).
3814
+ #
2489
3815
  class HTTPConflict < HTTPClientError
2490
3816
  HAS_BODY: bool
2491
3817
  end
2492
3818
 
3819
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3820
+ # Response class for `Gone` responses (status code 410).
3821
+ #
3822
+ # The resource requested was previously in use but is no longer available and
3823
+ # will not be available again. See [410
3824
+ # Gone](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#410).
3825
+ #
2493
3826
  class HTTPGone < HTTPClientError
2494
3827
  HAS_BODY: bool
2495
3828
  end
2496
3829
 
3830
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3831
+ # Response class for `Length Required` responses (status code 411).
3832
+ #
3833
+ # The request did not specify the length of its content, which is required by
3834
+ # the requested resource. See [411 Length
3835
+ # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#411).
3836
+ #
2497
3837
  class HTTPLengthRequired < HTTPClientError
2498
3838
  HAS_BODY: bool
2499
3839
  end
2500
3840
 
3841
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3842
+ # Response class for `Precondition Failed` responses (status code 412).
3843
+ #
3844
+ # The server does not meet one of the preconditions specified in the request
3845
+ # headers. See [412 Precondition
3846
+ # Failed](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#412).
3847
+ #
2501
3848
  class HTTPPreconditionFailed < HTTPClientError
2502
3849
  HAS_BODY: bool
2503
3850
  end
2504
3851
 
3852
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3853
+ # Response class for `Payload Too Large` responses (status code 413).
3854
+ #
3855
+ # The request is larger than the server is willing or able to process. See [413
3856
+ # Payload Too
3857
+ # Large](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413).
3858
+ #
2505
3859
  class HTTPPayloadTooLarge < HTTPClientError
2506
3860
  HAS_BODY: bool
2507
3861
  end
2508
3862
 
3863
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3864
+ # Response class for `URI Too Long` responses (status code 414).
3865
+ #
3866
+ # The URI provided was too long for the server to process. See [414 URI Too
3867
+ # Long](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414).
3868
+ #
2509
3869
  class HTTPURITooLong < HTTPClientError
2510
3870
  HAS_BODY: bool
2511
3871
  end
2512
3872
 
3873
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3874
+ # Response class for `Unsupported Media Type` responses (status code 415).
3875
+ #
3876
+ # The request entity has a media type which the server or resource does not
3877
+ # support. See [415 Unsupported Media
3878
+ # Type](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415).
3879
+ #
2513
3880
  class HTTPUnsupportedMediaType < HTTPClientError
2514
3881
  HAS_BODY: bool
2515
3882
  end
2516
3883
 
3884
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3885
+ # Response class for `Range Not Satisfiable` responses (status code 416).
3886
+ #
3887
+ # The request entity has a media type which the server or resource does not
3888
+ # support. See [416 Range Not
3889
+ # Satisfiable](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416).
3890
+ #
2517
3891
  class HTTPRangeNotSatisfiable < HTTPClientError
2518
3892
  HAS_BODY: bool
2519
3893
  end
2520
3894
 
3895
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3896
+ # Response class for `Expectation Failed` responses (status code 417).
3897
+ #
3898
+ # The server cannot meet the requirements of the Expect request-header field.
3899
+ # See [417 Expectation
3900
+ # Failed](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#417).
3901
+ #
2521
3902
  class HTTPExpectationFailed < HTTPClientError
2522
3903
  HAS_BODY: bool
2523
3904
  end
2524
3905
 
3906
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3907
+ # Response class for `Misdirected Request` responses (status code 421).
3908
+ #
3909
+ # The request was directed at a server that is not able to produce a response.
3910
+ # See [421 Misdirected
3911
+ # Request](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421).
3912
+ #
2525
3913
  class HTTPMisdirectedRequest < HTTPClientError
2526
3914
  HAS_BODY: bool
2527
3915
  end
2528
3916
 
3917
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3918
+ # Response class for `Unprocessable Entity` responses (status code 422).
3919
+ #
3920
+ # The request was well-formed but had semantic errors. See [422 Unprocessable
3921
+ # Entity](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#422).
3922
+ #
2529
3923
  class HTTPUnprocessableEntity < HTTPClientError
2530
3924
  HAS_BODY: bool
2531
3925
  end
2532
3926
 
3927
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3928
+ # Response class for `Locked (WebDAV)` responses (status code 423).
3929
+ #
3930
+ # The requested resource is locked. See [423 Locked
3931
+ # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#423).
3932
+ #
2533
3933
  class HTTPLocked < HTTPClientError
2534
3934
  HAS_BODY: bool
2535
3935
  end
2536
3936
 
3937
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3938
+ # Response class for `Failed Dependency (WebDAV)` responses (status code 424).
3939
+ #
3940
+ # The request failed because it depended on another request and that request
3941
+ # failed. See [424 Failed Dependency
3942
+ # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424).
3943
+ #
2537
3944
  class HTTPFailedDependency < HTTPClientError
2538
3945
  HAS_BODY: bool
2539
3946
  end
2540
3947
 
3948
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3949
+ # Response class for `Upgrade Required` responses (status code 426).
3950
+ #
3951
+ # The client should switch to the protocol given in the Upgrade header field.
3952
+ # See [426 Upgrade
3953
+ # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#426).
3954
+ #
2541
3955
  class HTTPUpgradeRequired < HTTPClientError
2542
3956
  HAS_BODY: bool
2543
3957
  end
2544
3958
 
3959
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3960
+ # Response class for `Precondition Required` responses (status code 428).
3961
+ #
3962
+ # The origin server requires the request to be conditional. See [428
3963
+ # Precondition
3964
+ # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#428).
3965
+ #
2545
3966
  class HTTPPreconditionRequired < HTTPClientError
2546
3967
  HAS_BODY: bool
2547
3968
  end
2548
3969
 
3970
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3971
+ # Response class for `Too Many Requests` responses (status code 429).
3972
+ #
3973
+ # The user has sent too many requests in a given amount of time. See [429 Too
3974
+ # Many Requests](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429).
3975
+ #
2549
3976
  class HTTPTooManyRequests < HTTPClientError
2550
3977
  HAS_BODY: bool
2551
3978
  end
2552
3979
 
3980
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3981
+ # Response class for `Request Header Fields Too Large` responses (status code
3982
+ # 431).
3983
+ #
3984
+ # An individual header field is too large, or all the header fields
3985
+ # collectively, are too large. See [431 Request Header Fields Too
3986
+ # Large](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#431).
3987
+ #
2553
3988
  class HTTPRequestHeaderFieldsTooLarge < HTTPClientError
2554
3989
  HAS_BODY: bool
2555
3990
  end
2556
3991
 
3992
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
3993
+ # Response class for `Unavailable For Legal Reasons` responses (status code
3994
+ # 451).
3995
+ #
3996
+ # A server operator has received a legal demand to deny access to a resource or
3997
+ # to a set of resources that includes the requested resource. See [451
3998
+ # Unavailable For Legal
3999
+ # Reasons](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#451).
4000
+ #
2557
4001
  class HTTPUnavailableForLegalReasons < HTTPClientError
2558
4002
  HAS_BODY: bool
2559
4003
  end
2560
4004
 
4005
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
4006
+ # Response class for `Internal Server Error` responses (status code 500).
4007
+ #
4008
+ # An unexpected condition was encountered and no more specific message is
4009
+ # suitable. See [500 Internal Server
4010
+ # Error](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#500).
4011
+ #
2561
4012
  class HTTPInternalServerError < HTTPServerError
2562
4013
  HAS_BODY: bool
2563
4014
  end
2564
4015
 
4016
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
4017
+ # Response class for `Not Implemented` responses (status code 501).
4018
+ #
4019
+ # The server either does not recognize the request method, or it lacks the
4020
+ # ability to fulfil the request. See [501 Not
4021
+ # Implemented](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#501).
4022
+ #
2565
4023
  class HTTPNotImplemented < HTTPServerError
2566
4024
  HAS_BODY: bool
2567
4025
  end
2568
4026
 
4027
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
4028
+ # Response class for `Bad Gateway` responses (status code 502).
4029
+ #
4030
+ # The server was acting as a gateway or proxy and received an invalid response
4031
+ # from the upstream server. See [502 Bad
4032
+ # Gateway](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#502).
4033
+ #
2569
4034
  class HTTPBadGateway < HTTPServerError
2570
4035
  HAS_BODY: bool
2571
4036
  end
2572
4037
 
4038
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
4039
+ # Response class for `Service Unavailable` responses (status code 503).
4040
+ #
4041
+ # The server cannot handle the request (because it is overloaded or down for
4042
+ # maintenance). See [503 Service
4043
+ # Unavailable](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#503).
4044
+ #
2573
4045
  class HTTPServiceUnavailable < HTTPServerError
2574
4046
  HAS_BODY: bool
2575
4047
  end
2576
4048
 
4049
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
4050
+ # Response class for `Gateway Timeout` responses (status code 504).
4051
+ #
4052
+ # The server was acting as a gateway or proxy and did not receive a timely
4053
+ # response from the upstream server. See [504 Gateway
4054
+ # Timeout](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#504).
4055
+ #
2577
4056
  class HTTPGatewayTimeout < HTTPServerError
2578
4057
  HAS_BODY: bool
2579
4058
  end
2580
4059
 
4060
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
4061
+ # Response class for `HTTP Version Not Supported` responses (status code 505).
4062
+ #
4063
+ # The server does not support the HTTP version used in the request. See [505
4064
+ # HTTP Version Not
4065
+ # Supported](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#505).
4066
+ #
2581
4067
  class HTTPVersionNotSupported < HTTPServerError
2582
4068
  HAS_BODY: bool
2583
4069
  end
2584
4070
 
4071
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
4072
+ # Response class for `Variant Also Negotiates` responses (status code 506).
4073
+ #
4074
+ # Transparent content negotiation for the request results in a circular
4075
+ # reference. See [506 Variant Also
4076
+ # Negotiates](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506).
4077
+ #
2585
4078
  class HTTPVariantAlsoNegotiates < HTTPServerError
2586
4079
  HAS_BODY: bool
2587
4080
  end
2588
4081
 
4082
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
4083
+ # Response class for `Insufficient Storage (WebDAV)` responses (status code
4084
+ # 507).
4085
+ #
4086
+ # The server is unable to store the representation needed to complete the
4087
+ # request. See [507 Insufficient Storage
4088
+ # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#507).
4089
+ #
2589
4090
  class HTTPInsufficientStorage < HTTPServerError
2590
4091
  HAS_BODY: bool
2591
4092
  end
2592
4093
 
4094
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
4095
+ # Response class for `Loop Detected (WebDAV)` responses (status code 508).
4096
+ #
4097
+ # The server detected an infinite loop while processing the request. See [508
4098
+ # Loop Detected
4099
+ # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508).
4100
+ #
2593
4101
  class HTTPLoopDetected < HTTPServerError
2594
4102
  HAS_BODY: bool
2595
4103
  end
2596
4104
 
4105
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
4106
+ # Response class for `Not Extended` responses (status code 510).
4107
+ #
4108
+ # Further extensions to the request are required for the server to fulfill it.
4109
+ # See [510 Not
4110
+ # Extended](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510).
4111
+ #
2597
4112
  class HTTPNotExtended < HTTPServerError
2598
4113
  HAS_BODY: bool
2599
4114
  end
2600
4115
 
4116
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
4117
+ # Response class for `Network Authentication Required` responses (status code
4118
+ # 511).
4119
+ #
4120
+ # The client needs to authenticate to gain network access. See [511 Network
4121
+ # Authentication
4122
+ # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#511).
4123
+ #
2601
4124
  class HTTPNetworkAuthenticationRequired < HTTPServerError
2602
4125
  HAS_BODY: bool
2603
4126
  end
2604
4127
 
2605
4128
  # <!-- rdoc-file=lib/net/http/response.rb -->
2606
- # HTTP response class.
4129
+ # This class is the base class for Net::HTTP request classes.
4130
+ #
4131
+ # ## About the Examples
4132
+ #
4133
+ # Examples here assume that `net/http` has been required (which also requires
4134
+ # `uri`):
4135
+ #
4136
+ # require 'net/http'
4137
+ #
4138
+ # Many code examples here use these example websites:
4139
+ #
4140
+ # * https://jsonplaceholder.typicode.com.
4141
+ # * http://example.com.
4142
+ #
4143
+ #
4144
+ # Some examples also assume these variables:
4145
+ #
4146
+ # uri = URI('https://jsonplaceholder.typicode.com')
4147
+ # uri.freeze # Examples may not modify.
4148
+ # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
4149
+ # port = uri.port # => 443
4150
+ #
4151
+ # So that example requests may be written as:
4152
+ #
4153
+ # Net::HTTP.get(uri)
4154
+ # Net::HTTP.get(hostname, '/index.html')
4155
+ # Net::HTTP.start(hostname) do |http|
4156
+ # http.get('/todos/1')
4157
+ # http.get('/todos/2')
4158
+ # end
4159
+ #
4160
+ # An example that needs a modified URI first duplicates `uri`, then modifies the
4161
+ # duplicate:
4162
+ #
4163
+ # _uri = uri.dup
4164
+ # _uri.path = '/todos/1'
4165
+ #
4166
+ # ## Returned Responses
4167
+ #
4168
+ # Method Net::HTTP.get_response returns an instance of one of the subclasses of
4169
+ # Net::HTTPResponse:
4170
+ #
4171
+ # Net::HTTP.get_response(uri)
4172
+ # # => #<Net::HTTPOK 200 OK readbody=true>
4173
+ # Net::HTTP.get_response(hostname, '/nosuch')
4174
+ # # => #<Net::HTTPNotFound 404 Not Found readbody=true>
4175
+ #
4176
+ # As does method Net::HTTP#request:
4177
+ #
4178
+ # req = Net::HTTP::Get.new(uri)
4179
+ # Net::HTTP.start(hostname) do |http|
4180
+ # http.request(req)
4181
+ # end # => #<Net::HTTPOK 200 OK readbody=true>
2607
4182
  #
2608
- # This class wraps together the response header and the response body (the
2609
- # entity requested).
4183
+ # Class Net::HTTPResponse includes module Net::HTTPHeader, which provides access
4184
+ # to response header values via (among others):
2610
4185
  #
2611
- # It mixes in the HTTPHeader module, which provides access to response header
2612
- # values both via hash-like methods and via individual readers.
4186
+ # * Hash-like method `[]`.
4187
+ # * Specific reader methods, such as `content_type`.
4188
+ #
4189
+ #
4190
+ # Examples:
4191
+ #
4192
+ # res = Net::HTTP.get_response(uri) # => #<Net::HTTPOK 200 OK readbody=true>
4193
+ # res['Content-Type'] # => "text/html; charset=UTF-8"
4194
+ # res.content_type # => "text/html"
2613
4195
  #
2614
- # Note that each possible HTTP response code defines its own HTTPResponse
2615
- # subclass. All classes are defined under the Net module. Indentation indicates
2616
- # inheritance. For a list of the classes see Net::HTTP.
4196
+ # ## Response Subclasses
2617
4197
  #
2618
- # Correspondence `HTTP code => class` is stored in CODE_TO_OBJ constant:
4198
+ # Class Net::HTTPResponse has a subclass for each [HTTP status
4199
+ # code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes). You can look
4200
+ # up the response class for a given code:
2619
4201
  #
2620
- # Net::HTTPResponse::CODE_TO_OBJ['404'] #=> Net::HTTPNotFound
4202
+ # Net::HTTPResponse::CODE_TO_OBJ['200'] # => Net::HTTPOK
4203
+ # Net::HTTPResponse::CODE_TO_OBJ['400'] # => Net::HTTPBadRequest
4204
+ # Net::HTTPResponse::CODE_TO_OBJ['404'] # => Net::HTTPNotFound
4205
+ #
4206
+ # And you can retrieve the status code for a response object:
4207
+ #
4208
+ # Net::HTTP.get_response(uri).code # => "200"
4209
+ # Net::HTTP.get_response(hostname, '/nosuch').code # => "404"
4210
+ #
4211
+ # The response subclasses (indentation shows class hierarchy):
4212
+ #
4213
+ # * Net::HTTPUnknownResponse (for unhandled HTTP extensions).
4214
+ #
4215
+ # * Net::HTTPInformation:
4216
+ #
4217
+ # * Net::HTTPContinue (100)
4218
+ # * Net::HTTPSwitchProtocol (101)
4219
+ # * Net::HTTPProcessing (102)
4220
+ # * Net::HTTPEarlyHints (103)
4221
+ #
4222
+ #
4223
+ # * Net::HTTPSuccess:
4224
+ #
4225
+ # * Net::HTTPOK (200)
4226
+ # * Net::HTTPCreated (201)
4227
+ # * Net::HTTPAccepted (202)
4228
+ # * Net::HTTPNonAuthoritativeInformation (203)
4229
+ # * Net::HTTPNoContent (204)
4230
+ # * Net::HTTPResetContent (205)
4231
+ # * Net::HTTPPartialContent (206)
4232
+ # * Net::HTTPMultiStatus (207)
4233
+ # * Net::HTTPAlreadyReported (208)
4234
+ # * Net::HTTPIMUsed (226)
4235
+ #
4236
+ #
4237
+ # * Net::HTTPRedirection:
4238
+ #
4239
+ # * Net::HTTPMultipleChoices (300)
4240
+ # * Net::HTTPMovedPermanently (301)
4241
+ # * Net::HTTPFound (302)
4242
+ # * Net::HTTPSeeOther (303)
4243
+ # * Net::HTTPNotModified (304)
4244
+ # * Net::HTTPUseProxy (305)
4245
+ # * Net::HTTPTemporaryRedirect (307)
4246
+ # * Net::HTTPPermanentRedirect (308)
4247
+ #
4248
+ #
4249
+ # * Net::HTTPClientError:
4250
+ #
4251
+ # * Net::HTTPBadRequest (400)
4252
+ # * Net::HTTPUnauthorized (401)
4253
+ # * Net::HTTPPaymentRequired (402)
4254
+ # * Net::HTTPForbidden (403)
4255
+ # * Net::HTTPNotFound (404)
4256
+ # * Net::HTTPMethodNotAllowed (405)
4257
+ # * Net::HTTPNotAcceptable (406)
4258
+ # * Net::HTTPProxyAuthenticationRequired (407)
4259
+ # * Net::HTTPRequestTimeOut (408)
4260
+ # * Net::HTTPConflict (409)
4261
+ # * Net::HTTPGone (410)
4262
+ # * Net::HTTPLengthRequired (411)
4263
+ # * Net::HTTPPreconditionFailed (412)
4264
+ # * Net::HTTPRequestEntityTooLarge (413)
4265
+ # * Net::HTTPRequestURITooLong (414)
4266
+ # * Net::HTTPUnsupportedMediaType (415)
4267
+ # * Net::HTTPRequestedRangeNotSatisfiable (416)
4268
+ # * Net::HTTPExpectationFailed (417)
4269
+ # * Net::HTTPMisdirectedRequest (421)
4270
+ # * Net::HTTPUnprocessableEntity (422)
4271
+ # * Net::HTTPLocked (423)
4272
+ # * Net::HTTPFailedDependency (424)
4273
+ # * Net::HTTPUpgradeRequired (426)
4274
+ # * Net::HTTPPreconditionRequired (428)
4275
+ # * Net::HTTPTooManyRequests (429)
4276
+ # * Net::HTTPRequestHeaderFieldsTooLarge (431)
4277
+ # * Net::HTTPUnavailableForLegalReasons (451)
4278
+ #
4279
+ #
4280
+ # * Net::HTTPServerError:
4281
+ #
4282
+ # * Net::HTTPInternalServerError (500)
4283
+ # * Net::HTTPNotImplemented (501)
4284
+ # * Net::HTTPBadGateway (502)
4285
+ # * Net::HTTPServiceUnavailable (503)
4286
+ # * Net::HTTPGatewayTimeOut (504)
4287
+ # * Net::HTTPVersionNotSupported (505)
4288
+ # * Net::HTTPVariantAlsoNegotiates (506)
4289
+ # * Net::HTTPInsufficientStorage (507)
4290
+ # * Net::HTTPLoopDetected (508)
4291
+ # * Net::HTTPNotExtended (510)
4292
+ # * Net::HTTPNetworkAuthenticationRequired (511)
4293
+ #
4294
+ #
4295
+ #
4296
+ # There is also the Net::HTTPBadResponse exception which is raised when there is
4297
+ # a protocol error.
2621
4298
  #
2622
4299
  class HTTPResponse
2623
4300
  CODE_CLASS_TO_OBJ: Hash[untyped, untyped]