rbs 3.3.2 → 3.4.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -5
  3. data/.github/workflows/ruby.yml +7 -8
  4. data/.github/workflows/typecheck.yml +37 -0
  5. data/CHANGELOG.md +50 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +11 -11
  8. data/Steepfile +2 -2
  9. data/core/array.rbs +19 -49
  10. data/core/basic_object.rbs +2 -2
  11. data/core/comparable.rbs +17 -8
  12. data/core/complex.rbs +82 -43
  13. data/core/data.rbs +2 -4
  14. data/core/dir.rbs +635 -295
  15. data/core/enumerable.rbs +11 -18
  16. data/core/enumerator.rbs +37 -31
  17. data/core/errors.rbs +4 -0
  18. data/core/false_class.rbs +34 -15
  19. data/core/fiber.rbs +23 -0
  20. data/core/file.rbs +329 -120
  21. data/core/float.rbs +17 -32
  22. data/core/gc.rbs +17 -11
  23. data/core/hash.rbs +22 -44
  24. data/core/integer.rbs +82 -113
  25. data/core/io/buffer.rbs +90 -47
  26. data/core/io.rbs +39 -116
  27. data/core/kernel.rbs +442 -489
  28. data/core/match_data.rbs +55 -56
  29. data/core/module.rbs +45 -1
  30. data/core/nil_class.rbs +98 -35
  31. data/core/numeric.rbs +22 -32
  32. data/core/object_space/weak_key_map.rbs +102 -0
  33. data/core/process.rbs +1242 -655
  34. data/core/ractor.rbs +139 -120
  35. data/core/range.rbs +100 -4
  36. data/core/rational.rbs +0 -4
  37. data/core/rbs/unnamed/argf.rbs +16 -8
  38. data/core/rbs/unnamed/env_class.rbs +0 -24
  39. data/core/refinement.rbs +8 -0
  40. data/core/regexp.rbs +1149 -598
  41. data/core/ruby_vm.rbs +126 -12
  42. data/core/rubygems/platform.rbs +9 -0
  43. data/core/rubygems/rubygems.rbs +1 -1
  44. data/core/rubygems/version.rbs +5 -1
  45. data/core/set.rbs +20 -22
  46. data/core/signal.rbs +4 -4
  47. data/core/string.rbs +283 -230
  48. data/core/string_io.rbs +2 -14
  49. data/core/struct.rbs +404 -24
  50. data/core/symbol.rbs +1 -19
  51. data/core/thread.rbs +29 -12
  52. data/core/time.rbs +227 -104
  53. data/core/trace_point.rbs +2 -5
  54. data/core/true_class.rbs +54 -21
  55. data/core/warning.rbs +14 -11
  56. data/docs/data_and_struct.md +29 -0
  57. data/docs/syntax.md +3 -5
  58. data/docs/tools.md +1 -0
  59. data/ext/rbs_extension/lexer.c +643 -559
  60. data/ext/rbs_extension/lexer.re +5 -1
  61. data/ext/rbs_extension/parser.c +12 -3
  62. data/ext/rbs_extension/unescape.c +7 -47
  63. data/lib/rbs/cli/diff.rb +4 -1
  64. data/lib/rbs/cli/validate.rb +280 -0
  65. data/lib/rbs/cli.rb +2 -194
  66. data/lib/rbs/collection/config.rb +5 -6
  67. data/lib/rbs/collection/sources/git.rb +1 -1
  68. data/lib/rbs/collection.rb +1 -0
  69. data/lib/rbs/diff.rb +7 -4
  70. data/lib/rbs/errors.rb +11 -0
  71. data/lib/rbs/test/errors.rb +4 -1
  72. data/lib/rbs/test/guaranteed.rb +2 -3
  73. data/lib/rbs/test/type_check.rb +15 -10
  74. data/lib/rbs/test.rb +3 -3
  75. data/lib/rbs/types.rb +29 -0
  76. data/lib/rbs/unit_test/convertibles.rb +176 -0
  77. data/lib/rbs/unit_test/spy.rb +136 -0
  78. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  79. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  80. data/lib/rbs/unit_test.rb +6 -0
  81. data/lib/rbs/version.rb +1 -1
  82. data/sig/cli/validate.rbs +43 -0
  83. data/sig/diff.rbs +3 -1
  84. data/sig/errors.rbs +8 -0
  85. data/sig/rbs.rbs +1 -1
  86. data/sig/test/errors.rbs +52 -0
  87. data/sig/test/guranteed.rbs +9 -0
  88. data/sig/test/type_check.rbs +19 -0
  89. data/sig/test.rbs +82 -0
  90. data/sig/types.rbs +6 -1
  91. data/sig/unit_test/convertibles.rbs +154 -0
  92. data/sig/unit_test/spy.rbs +28 -0
  93. data/sig/unit_test/type_assertions.rbs +194 -0
  94. data/sig/unit_test/with_aliases.rbs +136 -0
  95. data/stdlib/base64/0/base64.rbs +307 -45
  96. data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
  97. data/stdlib/coverage/0/coverage.rbs +2 -2
  98. data/stdlib/csv/0/csv.rbs +25 -55
  99. data/stdlib/date/0/date.rbs +1 -43
  100. data/stdlib/date/0/date_time.rbs +1 -13
  101. data/stdlib/delegate/0/delegator.rbs +186 -0
  102. data/stdlib/delegate/0/kernel.rbs +47 -0
  103. data/stdlib/delegate/0/simple_delegator.rbs +98 -0
  104. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
  105. data/stdlib/erb/0/erb.rbs +2 -2
  106. data/stdlib/fileutils/0/fileutils.rbs +0 -19
  107. data/stdlib/io-console/0/io-console.rbs +12 -1
  108. data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
  109. data/stdlib/json/0/json.rbs +320 -81
  110. data/stdlib/logger/0/logger.rbs +9 -5
  111. data/stdlib/monitor/0/monitor.rbs +78 -0
  112. data/stdlib/net-http/0/net-http.rbs +1880 -543
  113. data/stdlib/objspace/0/objspace.rbs +19 -13
  114. data/stdlib/openssl/0/openssl.rbs +508 -127
  115. data/stdlib/optparse/0/optparse.rbs +25 -11
  116. data/stdlib/pathname/0/pathname.rbs +1 -1
  117. data/stdlib/pp/0/pp.rbs +2 -5
  118. data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
  119. data/stdlib/pstore/0/pstore.rbs +2 -4
  120. data/stdlib/rdoc/0/comment.rbs +1 -2
  121. data/stdlib/resolv/0/resolv.rbs +4 -2
  122. data/stdlib/socket/0/socket.rbs +2 -2
  123. data/stdlib/socket/0/unix_socket.rbs +2 -2
  124. data/stdlib/strscan/0/string_scanner.rbs +3 -2
  125. data/stdlib/tempfile/0/tempfile.rbs +1 -1
  126. data/stdlib/uri/0/common.rbs +245 -123
  127. metadata +23 -4
  128. data/lib/rbs/test/spy.rb +0 -6
@@ -8,7 +8,7 @@ module Net
8
8
  # <!-- rdoc-file=lib/net/http.rb -->
9
9
  # Class Net::HTTP provides a rich library that implements the client in a
10
10
  # client-server model that uses the HTTP request-response protocol. For
11
- # information about HTTP, see
11
+ # information about HTTP, see:
12
12
  #
13
13
  # * [Hypertext Transfer
14
14
  # Protocol](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol).
@@ -17,63 +17,6 @@ module Net
17
17
  # cal_overview).
18
18
  #
19
19
  #
20
- # Note: If you are performing only a few GET requests, consider using
21
- # [OpenURI](rdoc-ref:OpenURI); otherwise, read on.
22
- #
23
- # ## Synopsis
24
- #
25
- # If you are already familiar with HTTP, this synopsis may be helpful.
26
- #
27
- # [Session](rdoc-ref:Net::HTTP@Sessions) with multiple requests for [HTTP
28
- # methods](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_met
29
- # hods):
30
- #
31
- # Net::HTTP.start(hostname) do |http|
32
- # # Session started automatically before block execution.
33
- # http.get(path_or_uri, headers = {})
34
- # http.head(path_or_uri, headers = {})
35
- # http.post(path_or_uri, data, headers = {}) # Can also have a block.
36
- # http.put(path_or_uri, data, headers = {})
37
- # http.delete(path_or_uri, headers = {Depth: 'Infinity'})
38
- # http.options(path_or_uri, headers = {})
39
- # http.trace(path_or_uri, headers = {})
40
- # http.patch(path_or_uri, data, headers = {}) # Can also have a block.
41
- # # Session finished automatically at block exit.
42
- # end
43
- #
44
- # [Session](rdoc-ref:Net::HTTP@Sessions) with multiple requests for [WebDAV
45
- # methods](https://en.wikipedia.org/wiki/WebDAV#Implementation):
46
- #
47
- # Net::HTTP.start(hostname) do |http|
48
- # # Session started automatically before block execution.
49
- # http.copy(path_or_uri, headers = {})
50
- # http.lock(path_or_uri, body, headers = {})
51
- # http.mkcol(path_or_uri, body = nil, headers = {})
52
- # http.move(path_or_uri, headers = {})
53
- # http.propfind(path_or_uri, body = nil, headers = {'Depth' => '0'})
54
- # http.proppatch(path_or_uri, body, headers = {})
55
- # http.unlock(path_or_uri, body, headers = {})
56
- # # Session finished automatically at block exit.
57
- # end
58
- #
59
- # Each of the following methods automatically starts and finishes a
60
- # [session](rdoc-ref:Net::HTTP@Sessions) that sends a single request:
61
- #
62
- # # Return string response body.
63
- # Net::HTTP.get(hostname, path, port = 80)
64
- # Net::HTTP.get(uri, headers = {}, port = 80)
65
- #
66
- # # Write string response body to $stdout.
67
- # Net::HTTP.get_print(hostname, path_or_uri, port = 80)
68
- # Net::HTTP.get_print(uri, headers = {}, port = 80)
69
- #
70
- # # Return response as Net::HTTPResponse object.
71
- # Net::HTTP.get_response(hostname, path_or_uri, port = 80)
72
- # Net::HTTP.get_response(uri, headers = {}, port = 80)
73
- #
74
- # Net::HTTP.post(uri, data, headers = {})
75
- # Net::HTTP.post_form(uri, params)
76
- #
77
20
  # ## About the Examples
78
21
  #
79
22
  # Examples here assume that `net/http` has been required (which also requires
@@ -89,9 +32,10 @@ module Net
89
32
  #
90
33
  # Some examples also assume these variables:
91
34
  #
92
- # uri = URI('https://jsonplaceholder.typicode.com')
35
+ # uri = URI('https://jsonplaceholder.typicode.com/')
93
36
  # uri.freeze # Examples may not modify.
94
37
  # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
38
+ # path = uri.path # => "/"
95
39
  # port = uri.port # => 443
96
40
  #
97
41
  # So that example requests may be written as:
@@ -109,6 +53,64 @@ module Net
109
53
  # _uri = uri.dup
110
54
  # _uri.path = '/todos/1'
111
55
  #
56
+ # ## Strategies
57
+ #
58
+ # * If you will make only a few GET requests, consider using
59
+ # [OpenURI](rdoc-ref:OpenURI).
60
+ # * If you will make only a few requests of all kinds, consider using the
61
+ # various singleton convenience methods in this class. Each of the following
62
+ # methods automatically starts and finishes a
63
+ # [session](rdoc-ref:Net::HTTP@Sessions) that sends a single request:
64
+ #
65
+ # # Return string response body.
66
+ # Net::HTTP.get(hostname, path)
67
+ # Net::HTTP.get(uri)
68
+ #
69
+ # # Write string response body to $stdout.
70
+ # Net::HTTP.get_print(hostname, path)
71
+ # Net::HTTP.get_print(uri)
72
+ #
73
+ # # Return response as Net::HTTPResponse object.
74
+ # Net::HTTP.get_response(hostname, path)
75
+ # Net::HTTP.get_response(uri)
76
+ # data = '{"title": "foo", "body": "bar", "userId": 1}'
77
+ # Net::HTTP.post(uri, data)
78
+ # params = {title: 'foo', body: 'bar', userId: 1}
79
+ # Net::HTTP.post_form(uri, params)
80
+ #
81
+ # * If performance is important, consider using sessions, which lower request
82
+ # overhead. This [session](rdoc-ref:Net::HTTP@Sessions) has multiple
83
+ # requests for [HTTP
84
+ # methods](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request
85
+ # _methods) and [WebDAV
86
+ # methods](https://en.wikipedia.org/wiki/WebDAV#Implementation):
87
+ #
88
+ # Net::HTTP.start(hostname) do |http|
89
+ # # Session started automatically before block execution.
90
+ # http.get(path)
91
+ # http.head(path)
92
+ # body = 'Some text'
93
+ # http.post(path, body) # Can also have a block.
94
+ # http.put(path, body)
95
+ # http.delete(path)
96
+ # http.options(path)
97
+ # http.trace(path)
98
+ # http.patch(path, body) # Can also have a block.
99
+ # http.copy(path)
100
+ # http.lock(path, body)
101
+ # http.mkcol(path, body)
102
+ # http.move(path)
103
+ # http.propfind(path, body)
104
+ # http.proppatch(path, body)
105
+ # http.unlock(path, body)
106
+ # # Session finished automatically at block exit.
107
+ # end
108
+ #
109
+ #
110
+ # The methods cited above are convenience methods that, via their few arguments,
111
+ # allow minimal control over the requests. For greater control, consider using
112
+ # [request objects](rdoc-ref:Net::HTTPRequest).
113
+ #
112
114
  # ## URIs
113
115
  #
114
116
  # On the internet, a URI ([Universal Resource
@@ -184,7 +186,7 @@ module Net
184
186
  # Fields](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_field
185
187
  # s). A host may also accept other custom fields.
186
188
  #
187
- # ## Sessions
189
+ # ## HTTP Sessions
188
190
  #
189
191
  # A *session* is a connection between a server (host) and a client that:
190
192
  #
@@ -193,7 +195,7 @@ module Net
193
195
  # * Is ended by instance method Net::HTTP#finish.
194
196
  #
195
197
  #
196
- # See example sessions at the [Synopsis](rdoc-ref:Net::HTTP@Synopsis).
198
+ # See example sessions at [Strategies](rdoc-ref:Net::HTTP@Strategies).
197
199
  #
198
200
  # ### Session Using Net::HTTP.start
199
201
  #
@@ -284,49 +286,43 @@ module Net
284
286
  #
285
287
  # ## Following Redirection
286
288
  #
287
- # Each Net::HTTPResponse object belongs to a class for its response code.
288
- #
289
- # For example, all 2XX responses are instances of a Net::HTTPSuccess subclass, a
290
- # 3XX response is an instance of a Net::HTTPRedirection subclass and a 200
291
- # response is an instance of the Net::HTTPOK class. For details of response
292
- # classes, see the section "HTTP Response Classes" below.
289
+ # Each returned response is an instance of a subclass of Net::HTTPResponse. See
290
+ # the [response class
291
+ # hierarchy](rdoc-ref:Net::HTTPResponse@Response+Subclasses).
293
292
  #
294
- # Using a case statement you can handle various types of responses properly:
293
+ # In particular, class Net::HTTPRedirection is the parent of all redirection
294
+ # classes. This allows you to craft a case statement to handle redirections
295
+ # properly:
295
296
  #
296
- # def fetch(uri_str, limit = 10)
297
+ # def fetch(uri, limit = 10)
297
298
  # # You should choose a better exception.
298
- # raise ArgumentError, 'too many HTTP redirects' if limit == 0
299
- #
300
- # response = Net::HTTP.get_response(URI(uri_str))
301
- #
302
- # case response
303
- # when Net::HTTPSuccess then
304
- # response
305
- # when Net::HTTPRedirection then
306
- # location = response['location']
307
- # warn "redirected to #{location}"
299
+ # raise ArgumentError, 'Too many HTTP redirects' if limit == 0
300
+ #
301
+ # res = Net::HTTP.get_response(URI(uri))
302
+ # case res
303
+ # when Net::HTTPSuccess # Any success class.
304
+ # res
305
+ # when Net::HTTPRedirection # Any redirection class.
306
+ # location = res['Location']
307
+ # warn "Redirected to #{location}"
308
308
  # fetch(location, limit - 1)
309
- # else
310
- # response.value
309
+ # else # Any other class.
310
+ # res.value
311
311
  # end
312
312
  # end
313
313
  #
314
- # print fetch('http://www.ruby-lang.org')
314
+ # fetch(uri)
315
315
  #
316
316
  # ## Basic Authentication
317
317
  #
318
318
  # Basic authentication is performed according to
319
- # [RFC2617](http://www.ietf.org/rfc/rfc2617.txt).
320
- #
321
- # uri = URI('http://example.com/index.html?key=value')
319
+ # [RFC2617](http://www.ietf.org/rfc/rfc2617.txt):
322
320
  #
323
321
  # req = Net::HTTP::Get.new(uri)
324
- # req.basic_auth 'user', 'pass'
325
- #
326
- # res = Net::HTTP.start(uri.hostname, uri.port) {|http|
322
+ # req.basic_auth('user', 'pass')
323
+ # res = Net::HTTP.start(hostname) do |http|
327
324
  # http.request(req)
328
- # }
329
- # puts res.body
325
+ # end
330
326
  #
331
327
  # ## Streaming Response Bodies
332
328
  #
@@ -334,15 +330,12 @@ module Net
334
330
  # handling large files or wish to implement a progress bar you can instead
335
331
  # stream the body directly to an IO.
336
332
  #
337
- # uri = URI('http://example.com/large_file')
338
- #
339
- # Net::HTTP.start(uri.host, uri.port) do |http|
340
- # request = Net::HTTP::Get.new uri
341
- #
342
- # http.request request do |response|
343
- # open 'large_file', 'w' do |io|
344
- # response.read_body do |chunk|
345
- # io.write chunk
333
+ # Net::HTTP.start(hostname) do |http|
334
+ # req = Net::HTTP::Get.new(uri)
335
+ # http.request(req) do |res|
336
+ # open('t.tmp', 'w') do |f|
337
+ # res.read_body do |chunk|
338
+ # f.write chunk
346
339
  # end
347
340
  # end
348
341
  # end
@@ -350,50 +343,393 @@ module Net
350
343
  #
351
344
  # ## HTTPS
352
345
  #
353
- # HTTPS is enabled for an HTTP connection by Net::HTTP#use_ssl=.
354
- #
355
- # uri = URI('https://secure.example.com/some_path?query=string')
346
+ # HTTPS is enabled for an HTTP connection by Net::HTTP#use_ssl=:
356
347
  #
357
- # Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
358
- # request = Net::HTTP::Get.new uri
359
- # response = http.request request # Net::HTTPResponse object
348
+ # Net::HTTP.start(hostname, :use_ssl => true) do |http|
349
+ # req = Net::HTTP::Get.new(uri)
350
+ # res = http.request(req)
360
351
  # end
361
352
  #
362
- # Or if you simply want to make a GET request, you may pass in an URI object
363
- # that has an HTTPS URL. Net::HTTP automatically turns on TLS verification if
364
- # the URI object has a 'https' URI scheme.
353
+ # Or if you simply want to make a GET request, you may pass in a URI object that
354
+ # has an HTTPS URL. Net::HTTP automatically turns on TLS verification if the URI
355
+ # object has a 'https' URI scheme:
365
356
  #
366
- # uri = URI('https://example.com/')
367
- # Net::HTTP.get(uri) # => String
357
+ # uri # => #<URI::HTTPS https://jsonplaceholder.typicode.com/>
358
+ # Net::HTTP.get(uri)
359
+ #
360
+ # ## Proxy Server
361
+ #
362
+ # An HTTP object can have a [proxy
363
+ # server](https://en.wikipedia.org/wiki/Proxy_server).
364
+ #
365
+ # You can create an HTTP object with a proxy server using method Net::HTTP.new
366
+ # or method Net::HTTP.start.
367
+ #
368
+ # The proxy may be defined either by argument `p_addr` or by environment
369
+ # variable `'http_proxy'`.
370
+ #
371
+ # ### Proxy Using Argument `p_addr` as a String
372
+ #
373
+ # When argument `p_addr` is a string hostname, the returned `http` has the given
374
+ # host as its proxy:
375
+ #
376
+ # http = Net::HTTP.new(hostname, nil, 'proxy.example')
377
+ # http.proxy? # => true
378
+ # http.proxy_from_env? # => false
379
+ # http.proxy_address # => "proxy.example"
380
+ # # These use default values.
381
+ # http.proxy_port # => 80
382
+ # http.proxy_user # => nil
383
+ # http.proxy_pass # => nil
384
+ #
385
+ # The port, username, and password for the proxy may also be given:
386
+ #
387
+ # http = Net::HTTP.new(hostname, nil, 'proxy.example', 8000, 'pname', 'ppass')
388
+ # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
389
+ # http.proxy? # => true
390
+ # http.proxy_from_env? # => false
391
+ # http.proxy_address # => "proxy.example"
392
+ # http.proxy_port # => 8000
393
+ # http.proxy_user # => "pname"
394
+ # http.proxy_pass # => "ppass"
395
+ #
396
+ # ### Proxy Using '`ENV['http_proxy']`'
397
+ #
398
+ # When environment variable `'http_proxy'` is set to a URI string, the returned
399
+ # `http` will have the server at that URI as its proxy; note that the URI string
400
+ # must have a protocol such as `'http'` or `'https'`:
401
+ #
402
+ # ENV['http_proxy'] = 'http://example.com'
403
+ # http = Net::HTTP.new(hostname)
404
+ # http.proxy? # => true
405
+ # http.proxy_from_env? # => true
406
+ # http.proxy_address # => "example.com"
407
+ # # These use default values.
408
+ # http.proxy_port # => 80
409
+ # http.proxy_user # => nil
410
+ # http.proxy_pass # => nil
411
+ #
412
+ # The URI string may include proxy username, password, and port number:
413
+ #
414
+ # ENV['http_proxy'] = 'http://pname:ppass@example.com:8000'
415
+ # http = Net::HTTP.new(hostname)
416
+ # http.proxy? # => true
417
+ # http.proxy_from_env? # => true
418
+ # http.proxy_address # => "example.com"
419
+ # http.proxy_port # => 8000
420
+ # http.proxy_user # => "pname"
421
+ # http.proxy_pass # => "ppass"
422
+ #
423
+ # ### Filtering Proxies
424
+ #
425
+ # With method Net::HTTP.new (but not Net::HTTP.start), you can use argument
426
+ # `p_no_proxy` to filter proxies:
427
+ #
428
+ # * Reject a certain address:
368
429
  #
369
- # In previous versions of Ruby you would need to require 'net/https' to use
370
- # HTTPS. This is no longer true.
430
+ # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example')
431
+ # http.proxy_address # => nil
371
432
  #
372
- # ## Proxies
433
+ # * Reject certain domains or subdomains:
373
434
  #
374
- # Net::HTTP will automatically create a proxy from the `http_proxy` environment
375
- # variable if it is present. To disable use of `http_proxy`, pass `nil` for the
376
- # proxy address.
435
+ # http = Net::HTTP.new('example.com', nil, 'my.proxy.example', 8000, 'pname', 'ppass', 'proxy.example')
436
+ # http.proxy_address # => nil
377
437
  #
378
- # You may also create a custom proxy:
438
+ # * Reject certain addresses and port combinations:
379
439
  #
380
- # proxy_addr = 'your.proxy.host'
381
- # proxy_port = 8080
440
+ # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:1234')
441
+ # http.proxy_address # => "proxy.example"
382
442
  #
383
- # Net::HTTP.new('example.com', nil, proxy_addr, proxy_port).start { |http|
384
- # # always proxy via your.proxy.addr:8080
385
- # }
443
+ # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:8000')
444
+ # http.proxy_address # => nil
386
445
  #
387
- # See Net::HTTP.new for further details and examples such as proxies that
388
- # require a username and password.
446
+ # * Reject a list of the types above delimited using a comma:
389
447
  #
390
- # ## Compression
448
+ # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000')
449
+ # http.proxy_address # => nil
391
450
  #
392
- # Net::HTTP automatically adds Accept-Encoding for compression of response
393
- # bodies and automatically decompresses gzip and deflate responses unless a
394
- # Range header was sent.
451
+ # http = Net::HTTP.new('example.com', nil, 'my.proxy', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000')
452
+ # http.proxy_address # => nil
395
453
  #
396
- # Compression can be disabled through the Accept-Encoding: identity header.
454
+ #
455
+ # ## Compression and Decompression
456
+ #
457
+ # Net::HTTP does not compress the body of a request before sending.
458
+ #
459
+ # By default, Net::HTTP adds header `'Accept-Encoding'` to a new [request
460
+ # object](rdoc-ref:Net::HTTPRequest):
461
+ #
462
+ # Net::HTTP::Get.new(uri)['Accept-Encoding']
463
+ # # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
464
+ #
465
+ # This requests the server to zip-encode the response body if there is one; the
466
+ # server is not required to do so.
467
+ #
468
+ # Net::HTTP does not automatically decompress a response body if the response
469
+ # has header `'Content-Range'`.
470
+ #
471
+ # Otherwise decompression (or not) depends on the value of header
472
+ # [Content-Encoding](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#co
473
+ # ntent-encoding-response-header):
474
+ #
475
+ # * `'deflate'`, `'gzip'`, or `'x-gzip'`: decompresses the body and deletes
476
+ # the header.
477
+ # * `'none'` or `'identity'`: does not decompress the body, but deletes the
478
+ # header.
479
+ # * Any other value: leaves the body and header unchanged.
480
+ #
481
+ #
482
+ # ## What's Here
483
+ #
484
+ # This is a categorized summary of methods and attributes.
485
+ #
486
+ # ### Net::HTTP Objects
487
+ #
488
+ # * [::new](rdoc-ref:Net::HTTP.new): Creates a new instance.
489
+ # * [#inspect](rdoc-ref:Net::HTTP#inspect): Returns a string representation of
490
+ # `self`.
491
+ #
492
+ #
493
+ # ### Sessions
494
+ #
495
+ # * [::start](rdoc-ref:Net::HTTP.start): Begins a new session in a new
496
+ # Net::HTTP object.
497
+ # * [#started?](rdoc-ref:Net::HTTP#started?) (aliased as
498
+ # [#active?](rdoc-ref:Net::HTTP#active?)): Returns whether in a session.
499
+ # * [#finish](rdoc-ref:Net::HTTP#finish): Ends an active session.
500
+ # * [#start](rdoc-ref:Net::HTTP#start): Begins a new session in an existing
501
+ # Net::HTTP object (`self`).
502
+ #
503
+ #
504
+ # ### Connections
505
+ #
506
+ # * [:continue_timeout](rdoc-ref:Net::HTTP#continue_timeout): Returns the
507
+ # continue timeout.
508
+ # * [#continue_timeout=](rdoc-ref:Net::HTTP#continue_timeout=): Sets the
509
+ # continue timeout seconds.
510
+ # * [:keep_alive_timeout](rdoc-ref:Net::HTTP#keep_alive_timeout): Returns the
511
+ # keep-alive timeout.
512
+ # * [:keep_alive_timeout=](rdoc-ref:Net::HTTP#keep_alive_timeout=): Sets the
513
+ # keep-alive timeout.
514
+ # * [:max_retries](rdoc-ref:Net::HTTP#max_retries): Returns the maximum
515
+ # retries.
516
+ # * [#max_retries=](rdoc-ref:Net::HTTP#max_retries=): Sets the maximum
517
+ # retries.
518
+ # * [:open_timeout](rdoc-ref:Net::HTTP#open_timeout): Returns the open
519
+ # timeout.
520
+ # * [:open_timeout=](rdoc-ref:Net::HTTP#open_timeout=): Sets the open timeout.
521
+ # * [:read_timeout](rdoc-ref:Net::HTTP#read_timeout): Returns the open
522
+ # timeout.
523
+ # * [:read_timeout=](rdoc-ref:Net::HTTP#read_timeout=): Sets the read timeout.
524
+ # * [:ssl_timeout](rdoc-ref:Net::HTTP#ssl_timeout): Returns the ssl timeout.
525
+ # * [:ssl_timeout=](rdoc-ref:Net::HTTP#ssl_timeout=): Sets the ssl timeout.
526
+ # * [:write_timeout](rdoc-ref:Net::HTTP#write_timeout): Returns the write
527
+ # timeout.
528
+ # * [write_timeout=](rdoc-ref:Net::HTTP#write_timeout=): Sets the write
529
+ # timeout.
530
+ #
531
+ #
532
+ # ### Requests
533
+ #
534
+ # * [::get](rdoc-ref:Net::HTTP.get): Sends a GET request and returns the
535
+ # string response body.
536
+ # * [::get_print](rdoc-ref:Net::HTTP.get_print): Sends a GET request and write
537
+ # the string response body to $stdout.
538
+ # * [::get_response](rdoc-ref:Net::HTTP.get_response): Sends a GET request and
539
+ # returns a response object.
540
+ # * [::post_form](rdoc-ref:Net::HTTP.post_form): Sends a POST request with
541
+ # form data and returns a response object.
542
+ # * [::post](rdoc-ref:Net::HTTP.post): Sends a POST request with data and
543
+ # returns a response object.
544
+ # * [#copy](rdoc-ref:Net::HTTP#copy): Sends a COPY request and returns a
545
+ # response object.
546
+ # * [#delete](rdoc-ref:Net::HTTP#delete): Sends a DELETE request and returns a
547
+ # response object.
548
+ # * [#get](rdoc-ref:Net::HTTP#get): Sends a GET request and returns a response
549
+ # object.
550
+ # * [#head](rdoc-ref:Net::HTTP#head): Sends a HEAD request and returns a
551
+ # response object.
552
+ # * [#lock](rdoc-ref:Net::HTTP#lock): Sends a LOCK request and returns a
553
+ # response object.
554
+ # * [#mkcol](rdoc-ref:Net::HTTP#mkcol): Sends a MKCOL request and returns a
555
+ # response object.
556
+ # * [#move](rdoc-ref:Net::HTTP#move): Sends a MOVE request and returns a
557
+ # response object.
558
+ # * [#options](rdoc-ref:Net::HTTP#options): Sends a OPTIONS request and
559
+ # returns a response object.
560
+ # * [#patch](rdoc-ref:Net::HTTP#patch): Sends a PATCH request and returns a
561
+ # response object.
562
+ # * [#post](rdoc-ref:Net::HTTP#post): Sends a POST request and returns a
563
+ # response object.
564
+ # * [#propfind](rdoc-ref:Net::HTTP#propfind): Sends a PROPFIND request and
565
+ # returns a response object.
566
+ # * [#proppatch](rdoc-ref:Net::HTTP#proppatch): Sends a PROPPATCH request and
567
+ # returns a response object.
568
+ # * [#put](rdoc-ref:Net::HTTP#put): Sends a PUT request and returns a response
569
+ # object.
570
+ # * [#request](rdoc-ref:Net::HTTP#request): Sends a request and returns a
571
+ # response object.
572
+ # * [#request_get](rdoc-ref:Net::HTTP#request_get) (aliased as
573
+ # [#get2](rdoc-ref:Net::HTTP#get2)): Sends a GET request and forms a
574
+ # response object; if a block given, calls the block with the object,
575
+ # otherwise returns the object.
576
+ # * [#request_head](rdoc-ref:Net::HTTP#request_head) (aliased as
577
+ # [#head2](rdoc-ref:Net::HTTP#head2)): Sends a HEAD request and forms a
578
+ # response object; if a block given, calls the block with the object,
579
+ # otherwise returns the object.
580
+ # * [#request_post](rdoc-ref:Net::HTTP#request_post) (aliased as
581
+ # [#post2](rdoc-ref:Net::HTTP#post2)): Sends a POST request and forms a
582
+ # response object; if a block given, calls the block with the object,
583
+ # otherwise returns the object.
584
+ # * [#send_request](rdoc-ref:Net::HTTP#send_request): Sends a request and
585
+ # returns a response object.
586
+ # * [#trace](rdoc-ref:Net::HTTP#trace): Sends a TRACE request and returns a
587
+ # response object.
588
+ # * [#unlock](rdoc-ref:Net::HTTP#unlock): Sends an UNLOCK request and returns
589
+ # a response object.
590
+ #
591
+ #
592
+ # ### Responses
593
+ #
594
+ # * [:close_on_empty_response](rdoc-ref:Net::HTTP#close_on_empty_response):
595
+ # Returns whether to close connection on empty response.
596
+ # * [:close_on_empty_response=](rdoc-ref:Net::HTTP#close_on_empty_response=):
597
+ # Sets whether to close connection on empty response.
598
+ # * [:ignore_eof](rdoc-ref:Net::HTTP#ignore_eof): Returns whether to ignore
599
+ # end-of-file when reading a response body with `Content-Length` headers.
600
+ # * [:ignore_eof=](rdoc-ref:Net::HTTP#ignore_eof=): Sets whether to ignore
601
+ # end-of-file when reading a response body with `Content-Length` headers.
602
+ # * [:response_body_encoding](rdoc-ref:Net::HTTP#response_body_encoding):
603
+ # Returns the encoding to use for the response body.
604
+ # * [#response_body_encoding=](rdoc-ref:Net::HTTP#response_body_encoding=):
605
+ # Sets the response body encoding.
606
+ #
607
+ #
608
+ # ### Proxies
609
+ #
610
+ # * [:proxy_address](rdoc-ref:Net::HTTP#proxy_address): Returns the proxy
611
+ # address.
612
+ # * [:proxy_address=](rdoc-ref:Net::HTTP#proxy_address=): Sets the proxy
613
+ # address.
614
+ # * [::proxy_class?](rdoc-ref:Net::HTTP.proxy_class?): Returns whether `self`
615
+ # is a proxy class.
616
+ # * [#proxy?](rdoc-ref:Net::HTTP#proxy?): Returns whether `self` has a proxy.
617
+ # * [#proxy_address](rdoc-ref:Net::HTTP#proxy_address) (aliased as
618
+ # [#proxyaddr](rdoc-ref:Net::HTTP#proxyaddr)): Returns the proxy address.
619
+ # * [#proxy_from_env?](rdoc-ref:Net::HTTP#proxy_from_env?): Returns whether
620
+ # the proxy is taken from an environment variable.
621
+ # * [:proxy_from_env=](rdoc-ref:Net::HTTP#proxy_from_env=): Sets whether the
622
+ # proxy is to be taken from an environment variable.
623
+ # * [:proxy_pass](rdoc-ref:Net::HTTP#proxy_pass): Returns the proxy password.
624
+ # * [:proxy_pass=](rdoc-ref:Net::HTTP#proxy_pass=): Sets the proxy password.
625
+ # * [:proxy_port](rdoc-ref:Net::HTTP#proxy_port): Returns the proxy port.
626
+ # * [:proxy_port=](rdoc-ref:Net::HTTP#proxy_port=): Sets the proxy port.
627
+ # * [#proxy_user](rdoc-ref:Net::HTTP#proxy_user): Returns the proxy user name.
628
+ # * [:proxy_user=](rdoc-ref:Net::HTTP#proxy_user=): Sets the proxy user.
629
+ #
630
+ #
631
+ # ### Security
632
+ #
633
+ # * [:ca_file](rdoc-ref:Net::HTTP#ca_file): Returns the path to a CA
634
+ # certification file.
635
+ # * [:ca_file=](rdoc-ref:Net::HTTP#ca_file=): Sets the path to a CA
636
+ # certification file.
637
+ # * [:ca_path](rdoc-ref:Net::HTTP#ca_path): Returns the path of to CA
638
+ # directory containing certification files.
639
+ # * [:ca_path=](rdoc-ref:Net::HTTP#ca_path=): Sets the path of to CA directory
640
+ # containing certification files.
641
+ # * [:cert](rdoc-ref:Net::HTTP#cert): Returns the OpenSSL::X509::Certificate
642
+ # object to be used for client certification.
643
+ # * [:cert=](rdoc-ref:Net::HTTP#cert=): Sets the OpenSSL::X509::Certificate
644
+ # object to be used for client certification.
645
+ # * [:cert_store](rdoc-ref:Net::HTTP#cert_store): Returns the X509::Store to
646
+ # be used for verifying peer certificate.
647
+ # * [:cert_store=](rdoc-ref:Net::HTTP#cert_store=): Sets the X509::Store to be
648
+ # used for verifying peer certificate.
649
+ # * [:ciphers](rdoc-ref:Net::HTTP#ciphers): Returns the available SSL ciphers.
650
+ # * [:ciphers=](rdoc-ref:Net::HTTP#ciphers=): Sets the available SSL ciphers.
651
+ # * [:extra_chain_cert](rdoc-ref:Net::HTTP#extra_chain_cert): Returns the
652
+ # extra X509 certificates to be added to the certificate chain.
653
+ # * [:extra_chain_cert=](rdoc-ref:Net::HTTP#extra_chain_cert=): Sets the extra
654
+ # X509 certificates to be added to the certificate chain.
655
+ # * [:key](rdoc-ref:Net::HTTP#key): Returns the OpenSSL::PKey::RSA or
656
+ # OpenSSL::PKey::DSA object.
657
+ # * [:key=](rdoc-ref:Net::HTTP#key=): Sets the OpenSSL::PKey::RSA or
658
+ # OpenSSL::PKey::DSA object.
659
+ # * [:max_version](rdoc-ref:Net::HTTP#max_version): Returns the maximum SSL
660
+ # version.
661
+ # * [:max_version=](rdoc-ref:Net::HTTP#max_version=): Sets the maximum SSL
662
+ # version.
663
+ # * [:min_version](rdoc-ref:Net::HTTP#min_version): Returns the minimum SSL
664
+ # version.
665
+ # * [:min_version=](rdoc-ref:Net::HTTP#min_version=): Sets the minimum SSL
666
+ # version.
667
+ # * [#peer_cert](rdoc-ref:Net::HTTP#peer_cert): Returns the X509 certificate
668
+ # chain for the session's socket peer.
669
+ # * [:ssl_version](rdoc-ref:Net::HTTP#ssl_version): Returns the SSL version.
670
+ # * [:ssl_version=](rdoc-ref:Net::HTTP#ssl_version=): Sets the SSL version.
671
+ # * [#use_ssl=](rdoc-ref:Net::HTTP#use_ssl=): Sets whether a new session is to
672
+ # use Transport Layer Security.
673
+ # * [#use_ssl?](rdoc-ref:Net::HTTP#use_ssl?): Returns whether `self` uses SSL.
674
+ # * [:verify_callback](rdoc-ref:Net::HTTP#verify_callback): Returns the
675
+ # callback for the server certification verification.
676
+ # * [:verify_callback=](rdoc-ref:Net::HTTP#verify_callback=): Sets the
677
+ # callback for the server certification verification.
678
+ # * [:verify_depth](rdoc-ref:Net::HTTP#verify_depth): Returns the maximum
679
+ # depth for the certificate chain verification.
680
+ # * [:verify_depth=](rdoc-ref:Net::HTTP#verify_depth=): Sets the maximum depth
681
+ # for the certificate chain verification.
682
+ # * [:verify_hostname](rdoc-ref:Net::HTTP#verify_hostname): Returns the flags
683
+ # for server the certification verification at the beginning of the SSL/TLS
684
+ # session.
685
+ # * [:verify_hostname=](rdoc-ref:Net::HTTP#verify_hostname=): Sets he flags
686
+ # for server the certification verification at the beginning of the SSL/TLS
687
+ # session.
688
+ # * [:verify_mode](rdoc-ref:Net::HTTP#verify_mode): Returns the flags for
689
+ # server the certification verification at the beginning of the SSL/TLS
690
+ # session.
691
+ # * [:verify_mode=](rdoc-ref:Net::HTTP#verify_mode=): Sets the flags for
692
+ # server the certification verification at the beginning of the SSL/TLS
693
+ # session.
694
+ #
695
+ #
696
+ # ### Addresses and Ports
697
+ #
698
+ # * [:address](rdoc-ref:Net::HTTP#address): Returns the string host name or
699
+ # host IP.
700
+ # * [::default_port](rdoc-ref:Net::HTTP.default_port): Returns integer 80, the
701
+ # default port to use for HTTP requests.
702
+ # * [::http_default_port](rdoc-ref:Net::HTTP.http_default_port): Returns
703
+ # integer 80, the default port to use for HTTP requests.
704
+ # * [::https_default_port](rdoc-ref:Net::HTTP.https_default_port): Returns
705
+ # integer 443, the default port to use for HTTPS requests.
706
+ # * [#ipaddr](rdoc-ref:Net::HTTP#ipaddr): Returns the IP address for the
707
+ # connection.
708
+ # * [#ipaddr=](rdoc-ref:Net::HTTP#ipaddr=): Sets the IP address for the
709
+ # connection.
710
+ # * [:local_host](rdoc-ref:Net::HTTP#local_host): Returns the string local
711
+ # host used to establish the connection.
712
+ # * [:local_host=](rdoc-ref:Net::HTTP#local_host=): Sets the string local host
713
+ # used to establish the connection.
714
+ # * [:local_port](rdoc-ref:Net::HTTP#local_port): Returns the integer local
715
+ # port used to establish the connection.
716
+ # * [:local_port=](rdoc-ref:Net::HTTP#local_port=): Sets the integer local
717
+ # port used to establish the connection.
718
+ # * [:port](rdoc-ref:Net::HTTP#port): Returns the integer port number.
719
+ #
720
+ #
721
+ # ### HTTP Version
722
+ #
723
+ # * [::version_1_2?](rdoc-ref:Net::HTTP.version_1_2?) (aliased as
724
+ # [::is_version_1_2?](rdoc-ref:Net::HTTP.is_version_1_2?) and
725
+ # [::version_1_2](rdoc-ref:Net::HTTP.version_1_2)): Returns true; retained
726
+ # for compatibility.
727
+ #
728
+ #
729
+ # ### Debugging
730
+ #
731
+ # * [#set_debug_output](rdoc-ref:Net::HTTP#set_debug_output): Sets the output
732
+ # stream for debugging.
397
733
  #
398
734
  class HTTP < Protocol
399
735
  # :stopdoc:
@@ -549,7 +885,7 @@ module Net
549
885
  # rdoc-file=lib/net/http.rb
550
886
  # - default_port()
551
887
  # -->
552
- # Returns intger `80`, the default port to use for HTTP requests:
888
+ # Returns integer `80`, the default port to use for HTTP requests:
553
889
  #
554
890
  # Net::HTTP.default_port # => 80
555
891
  #
@@ -582,15 +918,12 @@ module Net
582
918
  # -->
583
919
  # Creates a new Net::HTTP object, `http`, via Net::HTTP.new:
584
920
  #
585
- # Net::HTTP.new(address, port, p_addr, p_port, p_user, p_pass)
586
- #
587
- # * For arguments `hostname` through `p_pass`, see Net::HTTP.new.
921
+ # * For arguments `address` and `port`, see Net::HTTP.new.
922
+ # * For proxy-defining arguments `p_addr` through `p_pass`, see [Proxy
923
+ # Server](rdoc-ref:Net::HTTP@Proxy+Server).
588
924
  # * For argument `opts`, see below.
589
925
  #
590
926
  #
591
- # Note: If `port` is `nil` and `opts[:use_ssl]` is a truthy value, the value
592
- # passed to `new` is Net::HTTP.https_default_port, not `port`.
593
- #
594
927
  # With no block given:
595
928
  #
596
929
  # * Calls `http.start` with no block (see #start), which opens a TCP
@@ -664,6 +997,10 @@ module Net
664
997
  # * #verify_mode
665
998
  # * #write_timeout
666
999
  #
1000
+ #
1001
+ # Note: If `port` is `nil` and `opts[:use_ssl]` is a truthy value, the value
1002
+ # passed to `new` is Net::HTTP.https_default_port, not `port`.
1003
+ #
667
1004
  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
668
1005
  | [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
669
1006
 
@@ -676,11 +1013,36 @@ module Net
676
1013
 
677
1014
  # <!--
678
1015
  # rdoc-file=lib/net/http.rb
679
- # - new(address, port = nil)
1016
+ # - new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil)
680
1017
  # -->
681
- # Creates a new Net::HTTP object for the specified server address, without
682
- # opening the TCP connection or initializing the HTTP session. The `address`
683
- # should be a DNS hostname or IP address.
1018
+ # Returns a new Net::HTTP object `http` (but does not open a TCP connection or
1019
+ # HTTP session).
1020
+ #
1021
+ # With only string argument `address` given (and `ENV['http_proxy']` undefined
1022
+ # or `nil`), the returned `http`:
1023
+ #
1024
+ # * Has the given address.
1025
+ # * Has the default port number, Net::HTTP.default_port (80).
1026
+ # * Has no proxy.
1027
+ #
1028
+ #
1029
+ # Example:
1030
+ #
1031
+ # http = Net::HTTP.new(hostname)
1032
+ # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
1033
+ # http.address # => "jsonplaceholder.typicode.com"
1034
+ # http.port # => 80
1035
+ # http.proxy? # => false
1036
+ #
1037
+ # With integer argument `port` also given, the returned `http` has the given
1038
+ # port:
1039
+ #
1040
+ # http = Net::HTTP.new(hostname, 8000)
1041
+ # # => #<Net::HTTP jsonplaceholder.typicode.com:8000 open=false>
1042
+ # http.port # => 8000
1043
+ #
1044
+ # For proxy-defining arguments `p_addr` through `p_no_proxy`, see [Proxy
1045
+ # Server](rdoc-ref:Net::HTTP@Proxy+Server).
684
1046
  #
685
1047
  def self.new: (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?untyped? p_no_proxy) -> Net::HTTP
686
1048
 
@@ -751,40 +1113,52 @@ module Net
751
1113
  def set_debug_output: (IO output) -> void
752
1114
 
753
1115
  # <!-- rdoc-file=lib/net/http.rb -->
754
- # The DNS host name or IP address to connect to.
1116
+ # Returns the string host name or host IP given as argument `address` in ::new.
755
1117
  #
756
1118
  attr_reader address: String
757
1119
 
758
1120
  # <!-- rdoc-file=lib/net/http.rb -->
759
- # The port number to connect to.
1121
+ # Returns the integer port number given as argument `port` in ::new.
760
1122
  #
761
1123
  attr_reader port: Integer
762
1124
 
763
1125
  # <!-- rdoc-file=lib/net/http.rb -->
764
- # The local host used to establish the connection.
1126
+ # Sets or returns the string local host used to establish the connection;
1127
+ # initially `nil`.
765
1128
  #
766
1129
  attr_accessor local_host: String
767
1130
 
768
1131
  # <!-- rdoc-file=lib/net/http.rb -->
769
- # The local port used to establish the connection.
1132
+ # Sets or returns the integer local port used to establish the connection;
1133
+ # initially `nil`.
770
1134
  #
771
1135
  attr_accessor local_port: Integer
772
1136
 
1137
+ # <!-- rdoc-file=lib/net/http.rb -->
1138
+ # Sets whether to determine the proxy from environment variable
1139
+ # '`ENV['http_proxy']`'; see [Proxy Using
1140
+ # ENV['http_proxy']](rdoc-ref:Net::HTTP@Proxy+Using+-27ENV-5B-27http_proxy-27-5D
1141
+ # -27).
1142
+ #
773
1143
  attr_writer proxy_from_env: untyped
774
1144
 
775
1145
  # <!-- rdoc-file=lib/net/http.rb -->
1146
+ # Sets the proxy address; see [Proxy Server](rdoc-ref:Net::HTTP@Proxy+Server).
776
1147
  #
777
1148
  attr_accessor proxy_address: String?
778
1149
 
779
1150
  # <!-- rdoc-file=lib/net/http.rb -->
1151
+ # Sets the proxy port; see [Proxy Server](rdoc-ref:Net::HTTP@Proxy+Server).
780
1152
  #
781
1153
  attr_accessor proxy_port: Integer?
782
1154
 
783
1155
  # <!-- rdoc-file=lib/net/http.rb -->
1156
+ # Sets the proxy user; see [Proxy Server](rdoc-ref:Net::HTTP@Proxy+Server).
784
1157
  #
785
1158
  attr_accessor proxy_user: String?
786
1159
 
787
1160
  # <!-- rdoc-file=lib/net/http.rb -->
1161
+ # Sets the proxy password; see [Proxy Server](rdoc-ref:Net::HTTP@Proxy+Server).
788
1162
  #
789
1163
  attr_accessor proxy_pass: String?
790
1164
 
@@ -825,18 +1199,15 @@ module Net
825
1199
  attr_accessor ipaddr: String?
826
1200
 
827
1201
  # <!-- rdoc-file=lib/net/http.rb -->
828
- # Number of seconds to wait for the connection to open. Any number may be used,
829
- # including Floats for fractional seconds. If the HTTP object cannot open a
830
- # connection in this many seconds, it raises a Net::OpenTimeout exception. The
831
- # default value is 60 seconds.
1202
+ # Sets or returns the numeric (Integer or Float) number of seconds to wait for a
1203
+ # connection to open; initially 60. If the connection is not made in the given
1204
+ # interval, an exception is raised.
832
1205
  #
833
1206
  attr_accessor open_timeout: Float | Integer
834
1207
 
835
1208
  # <!-- rdoc-file=lib/net/http.rb -->
836
- # Number of seconds to wait for one block to be read (via one read(2) call). Any
837
- # number may be used, including Floats for fractional seconds. If the HTTP
838
- # object cannot read data in this many seconds, it raises a Net::ReadTimeout
839
- # exception. The default value is 60 seconds.
1209
+ # Returns the numeric (Integer or Float) number of seconds to wait for one block
1210
+ # to be read (via one read(2) call); see #read_timeout=.
840
1211
  # ----
841
1212
  # <!--
842
1213
  # rdoc-file=lib/net/http.rb
@@ -856,11 +1227,8 @@ module Net
856
1227
  attr_accessor read_timeout: Float | Integer
857
1228
 
858
1229
  # <!-- rdoc-file=lib/net/http.rb -->
859
- # Number of seconds to wait for one block to be written (via one write(2) call).
860
- # Any number may be used, including Floats for fractional seconds. If the HTTP
861
- # object cannot write data in this many seconds, it raises a Net::WriteTimeout
862
- # exception. The default value is 60 seconds. Net::WriteTimeout is not raised on
863
- # Windows.
1230
+ # Returns the numeric (Integer or Float) number of seconds to wait for one block
1231
+ # to be written (via one write(2) call); see #write_timeout=.
864
1232
  # ----
865
1233
  # <!--
866
1234
  # rdoc-file=lib/net/http.rb
@@ -869,10 +1237,28 @@ module Net
869
1237
  # Sets the write timeout, in seconds, for `self` to integer `sec`; the initial
870
1238
  # value is 60.
871
1239
  #
872
- # Argument `sec` must be a non-negative numeric value.
1240
+ # Argument `sec` must be a non-negative numeric value:
1241
+ #
1242
+ # _uri = uri.dup
1243
+ # _uri.path = '/posts'
1244
+ # body = 'bar' * 200000
1245
+ # data = <<EOF
1246
+ # {"title": "foo", "body": "#{body}", "userId": "1"}
1247
+ # EOF
1248
+ # headers = {'content-type': 'application/json'}
1249
+ # http = Net::HTTP.new(hostname)
1250
+ # http.write_timeout # => 60
1251
+ # http.post(_uri.path, data, headers)
1252
+ # # => #<Net::HTTPCreated 201 Created readbody=true>
1253
+ # http.write_timeout = 0
1254
+ # http.post(_uri.path, data, headers) # Raises Net::WriteTimeout.
873
1255
  #
874
1256
  attr_accessor write_timeout: Float | Integer
875
1257
 
1258
+ # <!-- rdoc-file=lib/net/http.rb -->
1259
+ # Returns the maximum number of times to retry an idempotent request; see
1260
+ # #max_retries=.
1261
+ # ----
876
1262
  # <!--
877
1263
  # rdoc-file=lib/net/http.rb
878
1264
  # - max_retries=(retries)
@@ -890,22 +1276,23 @@ module Net
890
1276
  attr_accessor max_retries: Integer
891
1277
 
892
1278
  # <!-- rdoc-file=lib/net/http.rb -->
893
- # Seconds to wait for 100 Continue response. If the HTTP object does not receive
894
- # a response in this many seconds it sends the request body. The default value
895
- # is `nil`.
1279
+ # Returns the continue timeout value; see continue_timeout=.
896
1280
  # ----
897
1281
  # <!--
898
1282
  # rdoc-file=lib/net/http.rb
899
1283
  # - continue_timeout=(sec)
900
1284
  # -->
901
- # Setter for the continue_timeout attribute.
1285
+ # Sets the continue timeout value, which is the number of seconds to wait for an
1286
+ # expected 100 Continue response. If the HTTP object does not receive a response
1287
+ # in this many seconds it sends the request body.
902
1288
  #
903
1289
  attr_accessor continue_timeout: Float | Integer | nil
904
1290
 
905
1291
  # <!-- rdoc-file=lib/net/http.rb -->
906
- # Seconds to reuse the connection of the previous request. If the idle time is
907
- # less than this Keep-Alive Timeout, Net::HTTP reuses the TCP/IP socket used by
908
- # the previous communication. The default value is 2 seconds.
1292
+ # Sets or returns the numeric (Integer or Float) number of seconds to keep the
1293
+ # connection open after a request is sent; initially 2. If a new request is made
1294
+ # during the given interval, the still-open connection is used; otherwise the
1295
+ # connection will have been closed and a new connection is opened.
909
1296
  #
910
1297
  attr_accessor keep_alive_timeout: Float | Integer
911
1298
 
@@ -913,7 +1300,19 @@ module Net
913
1300
  # rdoc-file=lib/net/http.rb
914
1301
  # - started?()
915
1302
  # -->
916
- # Returns true if the HTTP session has been started.
1303
+ # Returns `true` if the HTTP session has been started:
1304
+ #
1305
+ # http = Net::HTTP.new(hostname)
1306
+ # http.started? # => false
1307
+ # http.start
1308
+ # http.started? # => true
1309
+ # http.finish # => nil
1310
+ # http.started? # => false
1311
+ #
1312
+ # Net::HTTP.start(hostname) do |http|
1313
+ # http.started?
1314
+ # end # => true
1315
+ # http.started? # => false
917
1316
  #
918
1317
  def started?: () -> bool
919
1318
 
@@ -924,13 +1323,17 @@ module Net
924
1323
  #
925
1324
  alias active? started?
926
1325
 
1326
+ # <!-- rdoc-file=lib/net/http.rb -->
1327
+ # Sets or returns whether to close the connection when the response is empty;
1328
+ # initially `false`.
1329
+ #
927
1330
  attr_accessor close_on_empty_response: untyped
928
1331
 
929
1332
  # <!--
930
1333
  # rdoc-file=lib/net/http.rb
931
1334
  # - use_ssl?()
932
1335
  # -->
933
- # Returns true if SSL/TLS is being used with HTTP.
1336
+ # Returns `true` if `self` uses SSL, `false` otherwise. See Net::HTTP#use_ssl=.
934
1337
  #
935
1338
  def use_ssl?: () -> bool
936
1339
 
@@ -938,8 +1341,12 @@ module Net
938
1341
  # rdoc-file=lib/net/http.rb
939
1342
  # - use_ssl=(flag)
940
1343
  # -->
941
- # Turn on/off SSL. This flag must be set before starting session. If you change
942
- # use_ssl value after session started, a Net::HTTP object raises IOError.
1344
+ # Sets whether a new session is to use [Transport Layer
1345
+ # Security](https://en.wikipedia.org/wiki/Transport_Layer_Security):
1346
+ #
1347
+ # Raises IOError if attempting to change during a session.
1348
+ #
1349
+ # Raises OpenSSL::SSL::SSLError if the port is not an HTTPS port.
943
1350
  #
944
1351
  def use_ssl=: (boolish flag) -> void
945
1352
 
@@ -948,87 +1355,95 @@ module Net
948
1355
  SSL_ATTRIBUTES: Array[Symbol]
949
1356
 
950
1357
  # <!-- rdoc-file=lib/net/http.rb -->
951
- # Sets path of a CA certification file in PEM format.
952
- #
953
- # The file can contain several CA certificates.
1358
+ # Sets or returns the path to a CA certification file in PEM format.
954
1359
  #
955
1360
  attr_accessor ca_file: untyped
956
1361
 
957
1362
  # <!-- rdoc-file=lib/net/http.rb -->
958
- # Sets path of a CA certification directory containing certifications in PEM
959
- # format.
1363
+ # Sets or returns the path of to CA directory containing certification files in
1364
+ # PEM format.
960
1365
  #
961
1366
  attr_accessor ca_path: untyped
962
1367
 
963
1368
  # <!-- rdoc-file=lib/net/http.rb -->
964
- # Sets an OpenSSL::X509::Certificate object as client certificate. (This method
965
- # is appeared in Michal Rokos's OpenSSL extension).
1369
+ # Sets or returns the OpenSSL::X509::Certificate object to be used for client
1370
+ # certification.
966
1371
  #
967
1372
  attr_accessor cert: untyped
968
1373
 
969
1374
  # <!-- rdoc-file=lib/net/http.rb -->
970
- # Sets the X509::Store to verify peer certificate.
1375
+ # Sets or returns the X509::Store to be used for verifying peer certificate.
971
1376
  #
972
1377
  attr_accessor cert_store: untyped
973
1378
 
974
1379
  # <!-- rdoc-file=lib/net/http.rb -->
975
- # Sets the available ciphers. See OpenSSL::SSL::SSLContext#ciphers=
1380
+ # Sets or returns the available SSL ciphers. See
1381
+ # [OpenSSL::SSL::SSLContext#ciphers=](rdoc-ref:OpenSSL::SSL::SSLContext#ciphers-
1382
+ # 3D).
976
1383
  #
977
1384
  attr_accessor ciphers: untyped
978
1385
 
979
1386
  # <!-- rdoc-file=lib/net/http.rb -->
980
- # Sets the extra X509 certificates to be added to the certificate chain. See
981
- # OpenSSL::SSL::SSLContext#extra_chain_cert=
1387
+ # Sets or returns the extra X509 certificates to be added to the certificate
1388
+ # chain. See
1389
+ # [OpenSSL::SSL::SSLContext#add_certificate](rdoc-ref:OpenSSL::SSL::SSLContext#a
1390
+ # dd_certificate).
982
1391
  #
983
1392
  attr_accessor extra_chain_cert: untyped
984
1393
 
985
1394
  # <!-- rdoc-file=lib/net/http.rb -->
986
- # Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object. (This method is
987
- # appeared in Michal Rokos's OpenSSL extension.)
1395
+ # Sets or returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
988
1396
  #
989
1397
  attr_accessor key: untyped
990
1398
 
991
1399
  # <!-- rdoc-file=lib/net/http.rb -->
992
- # Sets the SSL timeout seconds.
1400
+ # Sets or returns the SSL timeout seconds.
993
1401
  #
994
1402
  attr_accessor ssl_timeout: untyped
995
1403
 
996
1404
  # <!-- rdoc-file=lib/net/http.rb -->
997
- # Sets the SSL version. See OpenSSL::SSL::SSLContext#ssl_version=
1405
+ # Sets or returns the SSL version. See
1406
+ # [OpenSSL::SSL::SSLContext#ssl_version=](rdoc-ref:OpenSSL::SSL::SSLContext#ssl_
1407
+ # version-3D).
998
1408
  #
999
1409
  attr_accessor ssl_version: untyped
1000
1410
 
1001
1411
  # <!-- rdoc-file=lib/net/http.rb -->
1002
- # Sets the minimum SSL version. See OpenSSL::SSL::SSLContext#min_version=
1412
+ # Sets or returns the minimum SSL version. See
1413
+ # [OpenSSL::SSL::SSLContext#min_version=](rdoc-ref:OpenSSL::SSL::SSLContext#min_
1414
+ # version-3D).
1003
1415
  #
1004
1416
  attr_accessor min_version: untyped
1005
1417
 
1006
1418
  # <!-- rdoc-file=lib/net/http.rb -->
1007
- # Sets the maximum SSL version. See OpenSSL::SSL::SSLContext#max_version=
1419
+ # Sets or returns the maximum SSL version. See
1420
+ # [OpenSSL::SSL::SSLContext#max_version=](rdoc-ref:OpenSSL::SSL::SSLContext#max_
1421
+ # version-3D).
1008
1422
  #
1009
1423
  attr_accessor max_version: untyped
1010
1424
 
1011
1425
  # <!-- rdoc-file=lib/net/http.rb -->
1012
- # Sets the verify callback for the server certification verification.
1426
+ # Sets or returns the callback for the server certification verification.
1013
1427
  #
1014
1428
  attr_accessor verify_callback: untyped
1015
1429
 
1016
1430
  # <!-- rdoc-file=lib/net/http.rb -->
1017
- # Sets the maximum depth for the certificate chain verification.
1431
+ # Sets or returns the maximum depth for the certificate chain verification.
1018
1432
  #
1019
1433
  attr_accessor verify_depth: untyped
1020
1434
 
1021
1435
  # <!-- rdoc-file=lib/net/http.rb -->
1022
- # Sets the flags for server the certification verification at beginning of
1023
- # SSL/TLS session.
1024
- #
1025
- # OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER are acceptable.
1436
+ # Sets or returns the flags for server the certification verification at the
1437
+ # beginning of the SSL/TLS session. OpenSSL::SSL::VERIFY_NONE or
1438
+ # OpenSSL::SSL::VERIFY_PEER are acceptable.
1026
1439
  #
1027
1440
  attr_accessor verify_mode: untyped
1028
1441
 
1029
1442
  # <!-- rdoc-file=lib/net/http.rb -->
1030
- # Sets to check the server certificate is valid for the hostname. See
1031
- # OpenSSL::SSL::SSLContext#verify_hostname=
1443
+ # Sets or returns whether to verify that the server certificate is valid for the
1444
+ # hostname. See
1445
+ # [OpenSSL::SSL::SSLContext#verify_hostname=](rdoc-ref:OpenSSL::SSL::SSLContext#
1446
+ # attribute-i-verify_mode).
1032
1447
  #
1033
1448
  attr_accessor verify_hostname: untyped
1034
1449
 
@@ -1036,7 +1451,8 @@ module Net
1036
1451
  # rdoc-file=lib/net/http.rb
1037
1452
  # - peer_cert()
1038
1453
  # -->
1039
- # Returns the X.509 certificates the server presented.
1454
+ # Returns the X509 certificate chain (an array of strings) for the session's
1455
+ # socket peer, or `nil` if none.
1040
1456
  #
1041
1457
  def peer_cert: () -> (nil | untyped)
1042
1458
 
@@ -1044,14 +1460,25 @@ module Net
1044
1460
  # rdoc-file=lib/net/http.rb
1045
1461
  # - start() { |http| ... }
1046
1462
  # -->
1047
- # Opens a TCP connection and HTTP session.
1463
+ # Starts an HTTP session.
1464
+ #
1465
+ # Without a block, returns `self`:
1048
1466
  #
1049
- # When this method is called with a block, it passes the Net::HTTP object to the
1050
- # block, and closes the TCP connection and HTTP session after the block has been
1051
- # executed.
1467
+ # http = Net::HTTP.new(hostname)
1468
+ # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
1469
+ # http.start
1470
+ # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=true>
1471
+ # http.started? # => true
1472
+ # http.finish
1473
+ #
1474
+ # With a block, calls the block with `self`, finishes the session when the block
1475
+ # exits, and returns the block's value:
1052
1476
  #
1053
- # When called with a block, it returns the return value of the block; otherwise,
1054
- # it returns self.
1477
+ # http.start do |http|
1478
+ # http
1479
+ # end
1480
+ # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
1481
+ # http.started? # => false
1055
1482
  #
1056
1483
  def start: [T] () { (Net::HTTP) -> T } -> T
1057
1484
  | () -> Net::HTTP
@@ -1062,8 +1489,15 @@ module Net
1062
1489
  # rdoc-file=lib/net/http.rb
1063
1490
  # - finish()
1064
1491
  # -->
1065
- # Finishes the HTTP session and closes the TCP connection. Raises IOError if the
1066
- # session has not been started.
1492
+ # Finishes the HTTP session:
1493
+ #
1494
+ # http = Net::HTTP.new(hostname)
1495
+ # http.start
1496
+ # http.started? # => true
1497
+ # http.finish # => nil
1498
+ # http.started? # => false
1499
+ #
1500
+ # Raises IOError if not in a session.
1067
1501
  #
1068
1502
  def finish: () -> void
1069
1503
 
@@ -1085,27 +1519,31 @@ module Net
1085
1519
  # rdoc-file=lib/net/http.rb
1086
1520
  # - proxy_class?()
1087
1521
  # -->
1088
- # returns true if self is a class which was created by HTTP::Proxy.
1522
+ # Returns true if self is a class which was created by HTTP::Proxy.
1089
1523
  #
1090
1524
  def self.proxy_class?: () -> bool
1091
1525
 
1092
1526
  # <!-- rdoc-file=lib/net/http.rb -->
1093
- # Address of proxy host. If Net::HTTP does not use a proxy, nil.
1527
+ # Returns the address of the proxy host, or `nil` if none; see
1528
+ # Net::HTTP@Proxy+Server.
1094
1529
  #
1095
1530
  attr_reader self.proxy_address: String?
1096
1531
 
1097
1532
  # <!-- rdoc-file=lib/net/http.rb -->
1098
- # Port number of proxy host. If Net::HTTP does not use a proxy, nil.
1533
+ # Returns the port number of the proxy host, or `nil` if none; see
1534
+ # Net::HTTP@Proxy+Server.
1099
1535
  #
1100
1536
  attr_reader self.proxy_port: Integer?
1101
1537
 
1102
1538
  # <!-- rdoc-file=lib/net/http.rb -->
1103
- # User name for accessing proxy. If Net::HTTP does not use a proxy, nil.
1539
+ # Returns the user name for accessing the proxy, or `nil` if none; see
1540
+ # Net::HTTP@Proxy+Server.
1104
1541
  #
1105
1542
  attr_reader self.proxy_user: String?
1106
1543
 
1107
1544
  # <!-- rdoc-file=lib/net/http.rb -->
1108
- # User password for accessing proxy. If Net::HTTP does not use a proxy, nil.
1545
+ # Returns the password for accessing the proxy, or `nil` if none; see
1546
+ # Net::HTTP@Proxy+Server.
1109
1547
  #
1110
1548
  attr_reader self.proxy_pass: String?
1111
1549
 
@@ -1113,7 +1551,8 @@ module Net
1113
1551
  # rdoc-file=lib/net/http.rb
1114
1552
  # - proxy?()
1115
1553
  # -->
1116
- # True if requests for this connection will be proxied
1554
+ # Returns `true` if a proxy server is defined, `false` otherwise; see [Proxy
1555
+ # Server](rdoc-ref:Net::HTTP@Proxy+Server).
1117
1556
  #
1118
1557
  def proxy?: () -> bool
1119
1558
 
@@ -1121,7 +1560,8 @@ module Net
1121
1560
  # rdoc-file=lib/net/http.rb
1122
1561
  # - proxy_from_env?()
1123
1562
  # -->
1124
- # True if the proxy for this connection is determined from the environment
1563
+ # Returns `true` if the proxy server is defined in the environment, `false`
1564
+ # otherwise; see [Proxy Server](rdoc-ref:Net::HTTP@Proxy+Server).
1125
1565
  #
1126
1566
  def proxy_from_env?: () -> bool
1127
1567
 
@@ -1145,39 +1585,33 @@ module Net
1145
1585
 
1146
1586
  # <!--
1147
1587
  # rdoc-file=lib/net/http.rb
1148
- # - get(path, initheader = nil, dest = nil) { |body_segment| ... }
1588
+ # - get(path, initheader = nil) {|res| ... }
1149
1589
  # -->
1150
- # Retrieves data from `path` on the connected-to host which may be an absolute
1151
- # path String or a URI to extract the path from.
1590
+ # Sends a GET request to the server; returns an instance of a subclass of
1591
+ # Net::HTTPResponse.
1152
1592
  #
1153
- # `initheader` must be a Hash like { 'Accept' => '**/**', ... }, and it defaults
1154
- # to an empty hash. If `initheader` doesn't have the key 'accept-encoding', then
1155
- # a value of "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" is used, so that gzip
1156
- # compression is used in preference to deflate compression, which is used in
1157
- # preference to no compression. Ruby doesn't have libraries to support the
1158
- # compress (Lempel-Ziv) compression, so that is not supported. The intent of
1159
- # this is to reduce bandwidth by default. If this routine sets up compression,
1160
- # then it does the decompression also, removing the header as well to prevent
1161
- # confusion. Otherwise it leaves the body as it found it.
1593
+ # The request is based on the Net::HTTP::Get object created from string `path`
1594
+ # and initial headers hash `initheader`.
1162
1595
  #
1163
- # This method returns a Net::HTTPResponse object.
1596
+ # With a block given, calls the block with the response body:
1164
1597
  #
1165
- # If called with a block, yields each fragment of the entity body in turn as a
1166
- # string as it is read from the socket. Note that in this case, the returned
1167
- # response object will **not** contain a (meaningful) body.
1598
+ # http = Net::HTTP.new(hostname)
1599
+ # http.get('/todos/1') do |res|
1600
+ # p res
1601
+ # end # => #<Net::HTTPOK 200 OK readbody=true>
1168
1602
  #
1169
- # `dest` argument is obsolete. It still works but you must not use it.
1603
+ # Output:
1170
1604
  #
1171
- # This method never raises an exception.
1605
+ # "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}"
1172
1606
  #
1173
- # response = http.get('/index.html')
1607
+ # With no block given, simply returns the response object:
1174
1608
  #
1175
- # # using block
1176
- # File.open('result.txt', 'w') {|f|
1177
- # http.get('/~foo/') do |str|
1178
- # f.write str
1179
- # end
1180
- # }
1609
+ # http.get('/') # => #<Net::HTTPOK 200 OK readbody=true>
1610
+ #
1611
+ # Related:
1612
+ #
1613
+ # * Net::HTTP::Get: request class for HTTP method GET.
1614
+ # * Net::HTTP.get: sends GET request, returns response body.
1181
1615
  #
1182
1616
  def get: (String path, ?Hash[String, untyped] initheader, ?bot dest) ?{ (String body_segment) -> void } -> Net::HTTPResponse
1183
1617
 
@@ -1185,69 +1619,112 @@ module Net
1185
1619
  # rdoc-file=lib/net/http.rb
1186
1620
  # - head(path, initheader = nil)
1187
1621
  # -->
1188
- # Gets only the header from `path` on the connected-to host. `header` is a Hash
1189
- # like { 'Accept' => '**/**', ... }.
1622
+ # Sends a HEAD request to the server; returns an instance of a subclass of
1623
+ # Net::HTTPResponse.
1190
1624
  #
1191
- # This method returns a Net::HTTPResponse object.
1625
+ # The request is based on the Net::HTTP::Head object created from string `path`
1626
+ # and initial headers hash `initheader`:
1192
1627
  #
1193
- # This method never raises an exception.
1194
- #
1195
- # response = nil
1196
- # Net::HTTP.start('some.www.server', 80) {|http|
1197
- # response = http.head('/index.html')
1198
- # }
1199
- # p response['content-type']
1628
+ # res = http.head('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
1629
+ # res.body # => nil
1630
+ # res.to_hash.take(3)
1631
+ # # =>
1632
+ # [["date", ["Wed, 15 Feb 2023 15:25:42 GMT"]],
1633
+ # ["content-type", ["application/json; charset=utf-8"]],
1634
+ # ["connection", ["close"]]]
1200
1635
  #
1201
1636
  def head: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1202
1637
 
1203
1638
  # <!--
1204
1639
  # rdoc-file=lib/net/http.rb
1205
- # - post(path, data, initheader = nil, dest = nil) { |body_segment| ... }
1640
+ # - post(path, data, initheader = nil) {|res| ... }
1206
1641
  # -->
1207
- # Posts `data` (must be a String) to `path`. `header` must be a Hash like {
1208
- # 'Accept' => '**/**', ... }.
1642
+ # Sends a POST request to the server; returns an instance of a subclass of
1643
+ # Net::HTTPResponse.
1209
1644
  #
1210
- # This method returns a Net::HTTPResponse object.
1645
+ # The request is based on the Net::HTTP::Post object created from string `path`,
1646
+ # string `data`, and initial headers hash `initheader`.
1211
1647
  #
1212
- # If called with a block, yields each fragment of the entity body in turn as a
1213
- # string as it is read from the socket. Note that in this case, the returned
1214
- # response object will **not** contain a (meaningful) body.
1648
+ # With a block given, calls the block with the response body:
1215
1649
  #
1216
- # `dest` argument is obsolete. It still works but you must not use it.
1650
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1651
+ # http = Net::HTTP.new(hostname)
1652
+ # http.post('/todos', data) do |res|
1653
+ # p res
1654
+ # end # => #<Net::HTTPCreated 201 Created readbody=true>
1217
1655
  #
1218
- # This method never raises exception.
1656
+ # Output:
1219
1657
  #
1220
- # response = http.post('/cgi-bin/search.rb', 'query=foo')
1658
+ # "{\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\",\n \"id\": 201\n}"
1221
1659
  #
1222
- # # using block
1223
- # File.open('result.txt', 'w') {|f|
1224
- # http.post('/cgi-bin/search.rb', 'query=foo') do |str|
1225
- # f.write str
1226
- # end
1227
- # }
1660
+ # With no block given, simply returns the response object:
1228
1661
  #
1229
- # You should set Content-Type: header field for POST. If no Content-Type: field
1230
- # given, this method uses "application/x-www-form-urlencoded" by default.
1662
+ # http.post('/todos', data) # => #<Net::HTTPCreated 201 Created readbody=true>
1663
+ #
1664
+ # Related:
1665
+ #
1666
+ # * Net::HTTP::Post: request class for HTTP method POST.
1667
+ # * Net::HTTP.post: sends POST request, returns response body.
1231
1668
  #
1232
1669
  def post: (String path, String data, ?Hash[String, untyped] initheader, ?bot dest) ?{ (String body_segment) -> void } -> Net::HTTPResponse
1233
1670
 
1234
1671
  # <!--
1235
1672
  # rdoc-file=lib/net/http.rb
1236
- # - patch(path, data, initheader = nil, dest = nil) { |body_segment| ... }
1673
+ # - patch(path, data, initheader = nil) {|res| ... }
1237
1674
  # -->
1238
- # Sends a PATCH request to the `path` and gets a response, as an HTTPResponse
1239
- # object.
1675
+ # Sends a PATCH request to the server; returns an instance of a subclass of
1676
+ # Net::HTTPResponse.
1677
+ #
1678
+ # The request is based on the Net::HTTP::Patch object created from string
1679
+ # `path`, string `data`, and initial headers hash `initheader`.
1680
+ #
1681
+ # With a block given, calls the block with the response body:
1682
+ #
1683
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1684
+ # http = Net::HTTP.new(hostname)
1685
+ # http.patch('/todos/1', data) do |res|
1686
+ # p res
1687
+ # end # => #<Net::HTTPOK 200 OK readbody=true>
1688
+ #
1689
+ # Output:
1690
+ #
1691
+ # "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false,\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\"\n}"
1692
+ #
1693
+ # With no block given, simply returns the response object:
1694
+ #
1695
+ # http.patch('/todos/1', data) # => #<Net::HTTPCreated 201 Created readbody=true>
1240
1696
  #
1241
1697
  def patch: (String path, String data, ?Hash[String, untyped] initheader, ?bot dest) ?{ (String body_segment) -> void } -> Net::HTTPResponse
1242
1698
 
1699
+ # <!--
1700
+ # rdoc-file=lib/net/http.rb
1701
+ # - put(path, data, initheader = nil)
1702
+ # -->
1703
+ # Sends a PUT request to the server; returns an instance of a subclass of
1704
+ # Net::HTTPResponse.
1705
+ #
1706
+ # The request is based on the Net::HTTP::Put object created from string `path`,
1707
+ # string `data`, and initial headers hash `initheader`.
1708
+ #
1709
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1710
+ # http = Net::HTTP.new(hostname)
1711
+ # http.put('/todos/1', data) # => #<Net::HTTPOK 200 OK readbody=true>
1712
+ #
1243
1713
  def put: (String path, String data, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1244
1714
 
1245
1715
  # <!--
1246
1716
  # rdoc-file=lib/net/http.rb
1247
1717
  # - proppatch(path, body, initheader = nil)
1248
1718
  # -->
1249
- # Sends a PROPPATCH request to the `path` and gets a response, as an
1250
- # HTTPResponse object.
1719
+ # Sends a PROPPATCH request to the server; returns an instance of a subclass of
1720
+ # Net::HTTPResponse.
1721
+ #
1722
+ # The request is based on the Net::HTTP::Proppatch object created from string
1723
+ # `path`, string `body`, and initial headers hash `initheader`.
1724
+ #
1725
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1726
+ # http = Net::HTTP.new(hostname)
1727
+ # http.proppatch('/todos/1', data)
1251
1728
  #
1252
1729
  def proppatch: (String path, String body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1253
1730
 
@@ -1255,8 +1732,15 @@ module Net
1255
1732
  # rdoc-file=lib/net/http.rb
1256
1733
  # - lock(path, body, initheader = nil)
1257
1734
  # -->
1258
- # Sends a LOCK request to the `path` and gets a response, as an HTTPResponse
1259
- # object.
1735
+ # Sends a LOCK request to the server; returns an instance of a subclass of
1736
+ # Net::HTTPResponse.
1737
+ #
1738
+ # The request is based on the Net::HTTP::Lock object created from string `path`,
1739
+ # string `body`, and initial headers hash `initheader`.
1740
+ #
1741
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1742
+ # http = Net::HTTP.new(hostname)
1743
+ # http.lock('/todos/1', data)
1260
1744
  #
1261
1745
  def lock: (String path, String body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1262
1746
 
@@ -1264,8 +1748,15 @@ module Net
1264
1748
  # rdoc-file=lib/net/http.rb
1265
1749
  # - unlock(path, body, initheader = nil)
1266
1750
  # -->
1267
- # Sends a UNLOCK request to the `path` and gets a response, as an HTTPResponse
1268
- # object.
1751
+ # Sends an UNLOCK request to the server; returns an instance of a subclass of
1752
+ # Net::HTTPResponse.
1753
+ #
1754
+ # The request is based on the Net::HTTP::Unlock object created from string
1755
+ # `path`, string `body`, and initial headers hash `initheader`.
1756
+ #
1757
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1758
+ # http = Net::HTTP.new(hostname)
1759
+ # http.unlock('/todos/1', data)
1269
1760
  #
1270
1761
  def unlock: (String path, String body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1271
1762
 
@@ -1273,8 +1764,14 @@ module Net
1273
1764
  # rdoc-file=lib/net/http.rb
1274
1765
  # - options(path, initheader = nil)
1275
1766
  # -->
1276
- # Sends a OPTIONS request to the `path` and gets a response, as an HTTPResponse
1277
- # object.
1767
+ # Sends an Options request to the server; returns an instance of a subclass of
1768
+ # Net::HTTPResponse.
1769
+ #
1770
+ # The request is based on the Net::HTTP::Options object created from string
1771
+ # `path` and initial headers hash `initheader`.
1772
+ #
1773
+ # http = Net::HTTP.new(hostname)
1774
+ # http.options('/')
1278
1775
  #
1279
1776
  def options: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1280
1777
 
@@ -1282,8 +1779,15 @@ module Net
1282
1779
  # rdoc-file=lib/net/http.rb
1283
1780
  # - propfind(path, body = nil, initheader = {'Depth' => '0'})
1284
1781
  # -->
1285
- # Sends a PROPFIND request to the `path` and gets a response, as an HTTPResponse
1286
- # object.
1782
+ # Sends a PROPFIND request to the server; returns an instance of a subclass of
1783
+ # Net::HTTPResponse.
1784
+ #
1785
+ # The request is based on the Net::HTTP::Propfind object created from string
1786
+ # `path`, string `body`, and initial headers hash `initheader`.
1787
+ #
1788
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1789
+ # http = Net::HTTP.new(hostname)
1790
+ # http.propfind('/todos/1', data)
1287
1791
  #
1288
1792
  def propfind: (String path, ?untyped? body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1289
1793
 
@@ -1291,8 +1795,14 @@ module Net
1291
1795
  # rdoc-file=lib/net/http.rb
1292
1796
  # - delete(path, initheader = {'Depth' => 'Infinity'})
1293
1797
  # -->
1294
- # Sends a DELETE request to the `path` and gets a response, as an HTTPResponse
1295
- # object.
1798
+ # Sends a DELETE request to the server; returns an instance of a subclass of
1799
+ # Net::HTTPResponse.
1800
+ #
1801
+ # The request is based on the Net::HTTP::Delete object created from string
1802
+ # `path` and initial headers hash `initheader`.
1803
+ #
1804
+ # http = Net::HTTP.new(hostname)
1805
+ # http.delete('/todos/1')
1296
1806
  #
1297
1807
  def delete: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1298
1808
 
@@ -1300,8 +1810,14 @@ module Net
1300
1810
  # rdoc-file=lib/net/http.rb
1301
1811
  # - move(path, initheader = nil)
1302
1812
  # -->
1303
- # Sends a MOVE request to the `path` and gets a response, as an HTTPResponse
1304
- # object.
1813
+ # Sends a MOVE request to the server; returns an instance of a subclass of
1814
+ # Net::HTTPResponse.
1815
+ #
1816
+ # The request is based on the Net::HTTP::Move object created from string `path`
1817
+ # and initial headers hash `initheader`.
1818
+ #
1819
+ # http = Net::HTTP.new(hostname)
1820
+ # http.move('/todos/1')
1305
1821
  #
1306
1822
  def move: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1307
1823
 
@@ -1309,8 +1825,14 @@ module Net
1309
1825
  # rdoc-file=lib/net/http.rb
1310
1826
  # - copy(path, initheader = nil)
1311
1827
  # -->
1312
- # Sends a COPY request to the `path` and gets a response, as an HTTPResponse
1313
- # object.
1828
+ # Sends a COPY request to the server; returns an instance of a subclass of
1829
+ # Net::HTTPResponse.
1830
+ #
1831
+ # The request is based on the Net::HTTP::Copy object created from string `path`
1832
+ # and initial headers hash `initheader`.
1833
+ #
1834
+ # http = Net::HTTP.new(hostname)
1835
+ # http.copy('/todos/1')
1314
1836
  #
1315
1837
  def copy: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1316
1838
 
@@ -1318,8 +1840,15 @@ module Net
1318
1840
  # rdoc-file=lib/net/http.rb
1319
1841
  # - mkcol(path, body = nil, initheader = nil)
1320
1842
  # -->
1321
- # Sends a MKCOL request to the `path` and gets a response, as an HTTPResponse
1322
- # object.
1843
+ # Sends a MKCOL request to the server; returns an instance of a subclass of
1844
+ # Net::HTTPResponse.
1845
+ #
1846
+ # The request is based on the Net::HTTP::Mkcol object created from string
1847
+ # `path`, string `body`, and initial headers hash `initheader`.
1848
+ #
1849
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1850
+ # http.mkcol('/todos/1', data)
1851
+ # http = Net::HTTP.new(hostname)
1323
1852
  #
1324
1853
  def mkcol: (String path, ?untyped? body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1325
1854
 
@@ -1327,8 +1856,14 @@ module Net
1327
1856
  # rdoc-file=lib/net/http.rb
1328
1857
  # - trace(path, initheader = nil)
1329
1858
  # -->
1330
- # Sends a TRACE request to the `path` and gets a response, as an HTTPResponse
1331
- # object.
1859
+ # Sends a TRACE request to the server; returns an instance of a subclass of
1860
+ # Net::HTTPResponse.
1861
+ #
1862
+ # The request is based on the Net::HTTP::Trace object created from string `path`
1863
+ # and initial headers hash `initheader`.
1864
+ #
1865
+ # http = Net::HTTP.new(hostname)
1866
+ # http.trace('/todos/1')
1332
1867
  #
1333
1868
  def trace: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
1334
1869
 
@@ -1336,29 +1871,27 @@ module Net
1336
1871
  # rdoc-file=lib/net/http.rb
1337
1872
  # - request_get(path, initheader = nil) { |response| ... }
1338
1873
  # -->
1339
- # Sends a GET request to the `path`. Returns the response as a Net::HTTPResponse
1874
+ # Sends a GET request to the server; forms the response into a Net::HTTPResponse
1340
1875
  # object.
1341
1876
  #
1342
- # When called with a block, passes an HTTPResponse object to the block. The body
1343
- # of the response will not have been read yet; the block can process it using
1344
- # HTTPResponse#read_body, if desired.
1877
+ # The request is based on the Net::HTTP::Get object created from string `path`
1878
+ # and initial headers hash `initheader`.
1879
+ #
1880
+ # With no block given, returns the response object:
1345
1881
  #
1346
- # Returns the response.
1882
+ # http = Net::HTTP.new(hostname)
1883
+ # http.request_get('/todos') # => #<Net::HTTPOK 200 OK readbody=true>
1347
1884
  #
1348
- # This method never raises Net::* exceptions.
1885
+ # With a block given, calls the block with the response object and returns the
1886
+ # response object:
1349
1887
  #
1350
- # response = http.request_get('/index.html')
1351
- # # The entity body is already read in this case.
1352
- # p response['content-type']
1353
- # puts response.body
1888
+ # http.request_get('/todos') do |res|
1889
+ # p res
1890
+ # end # => #<Net::HTTPOK 200 OK readbody=true>
1354
1891
  #
1355
- # # Using a block
1356
- # http.request_get('/index.html') {|response|
1357
- # p response['content-type']
1358
- # response.read_body do |str| # read body now
1359
- # print str
1360
- # end
1361
- # }
1892
+ # Output:
1893
+ #
1894
+ # #<Net::HTTPOK 200 OK readbody=false>
1362
1895
  #
1363
1896
  def request_get: (String path, ?Hash[String, untyped] initheader) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
1364
1897
 
@@ -1366,15 +1899,14 @@ module Net
1366
1899
  # rdoc-file=lib/net/http.rb
1367
1900
  # - request_head(path, initheader = nil, &block)
1368
1901
  # -->
1369
- # Sends a HEAD request to the `path` and returns the response as a
1370
- # Net::HTTPResponse object.
1902
+ # Sends a HEAD request to the server; returns an instance of a subclass of
1903
+ # Net::HTTPResponse.
1371
1904
  #
1372
- # Returns the response.
1905
+ # The request is based on the Net::HTTP::Head object created from string `path`
1906
+ # and initial headers hash `initheader`.
1373
1907
  #
1374
- # This method never raises Net::* exceptions.
1375
- #
1376
- # response = http.request_head('/index.html')
1377
- # p response['content-type']
1908
+ # http = Net::HTTP.new(hostname)
1909
+ # http.head('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
1378
1910
  #
1379
1911
  def request_head: (String path, ?Hash[String, untyped] initheader) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
1380
1912
 
@@ -1382,31 +1914,28 @@ module Net
1382
1914
  # rdoc-file=lib/net/http.rb
1383
1915
  # - request_post(path, data, initheader = nil) { |response| ... }
1384
1916
  # -->
1385
- # Sends a POST request to the `path`.
1917
+ # Sends a POST request to the server; forms the response into a
1918
+ # Net::HTTPResponse object.
1386
1919
  #
1387
- # Returns the response as a Net::HTTPResponse object.
1920
+ # The request is based on the Net::HTTP::Post object created from string `path`,
1921
+ # string `data`, and initial headers hash `initheader`.
1388
1922
  #
1389
- # When called with a block, the block is passed an HTTPResponse object. The
1390
- # body of that response will not have been read yet; the block can process it
1391
- # using HTTPResponse#read_body, if desired.
1923
+ # With no block given, returns the response object:
1392
1924
  #
1393
- # Returns the response.
1925
+ # http = Net::HTTP.new(hostname)
1926
+ # http.post('/todos', 'xyzzy')
1927
+ # # => #<Net::HTTPCreated 201 Created readbody=true>
1394
1928
  #
1395
- # This method never raises Net::* exceptions.
1929
+ # With a block given, calls the block with the response body and returns the
1930
+ # response object:
1396
1931
  #
1397
- # # example
1398
- # response = http.request_post('/cgi-bin/nice.rb', 'datadatadata...')
1399
- # p response.status
1400
- # puts response.body # body is already read in this case
1932
+ # http.post('/todos', 'xyzzy') do |res|
1933
+ # p res
1934
+ # end # => #<Net::HTTPCreated 201 Created readbody=true>
1401
1935
  #
1402
- # # using block
1403
- # http.request_post('/cgi-bin/nice.rb', 'datadatadata...') {|response|
1404
- # p response.status
1405
- # p response['content-type']
1406
- # response.read_body do |str| # read body now
1407
- # print str
1408
- # end
1409
- # }
1936
+ # Output:
1937
+ #
1938
+ # "{\n \"xyzzy\": \"\",\n \"id\": 201\n}"
1410
1939
  #
1411
1940
  def request_post: (String path, String data, ?Hash[String, untyped] initheader) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
1412
1941
 
@@ -1439,15 +1968,24 @@ module Net
1439
1968
  # rdoc-file=lib/net/http.rb
1440
1969
  # - send_request(name, path, data = nil, header = nil)
1441
1970
  # -->
1442
- # Sends an HTTP request to the HTTP server. Also sends a DATA string if `data`
1443
- # is given.
1971
+ # Sends an HTTP request to the server; returns an instance of a subclass of
1972
+ # Net::HTTPResponse.
1444
1973
  #
1445
- # Returns a Net::HTTPResponse object.
1974
+ # The request is based on the Net::HTTPRequest object created from string
1975
+ # `path`, string `data`, and initial headers hash `header`. That object is an
1976
+ # instance of the [subclass of
1977
+ # Net::HTTPRequest](rdoc-ref:Net::HTTPRequest@Request+Subclasses), that
1978
+ # corresponds to the given uppercase string `name`, which must be an [HTTP
1979
+ # request method](https://en.wikipedia.org/wiki/HTTP#Request_methods) or a
1980
+ # [WebDAV request method](https://en.wikipedia.org/wiki/WebDAV#Implementation).
1446
1981
  #
1447
- # This method never raises Net::* exceptions.
1982
+ # Examples:
1448
1983
  #
1449
- # response = http.send_request('GET', '/index.html')
1450
- # puts response.body
1984
+ # http = Net::HTTP.new(hostname)
1985
+ # http.send_request('GET', '/todos/1')
1986
+ # # => #<Net::HTTPOK 200 OK readbody=true>
1987
+ # http.send_request('POST', '/todos', 'xyzzy')
1988
+ # # => #<Net::HTTPCreated 201 Created readbody=true>
1451
1989
  #
1452
1990
  def send_request: (String name, String path, ?String? data, ?Hash[String, untyped]? header) -> Net::HTTPResponse
1453
1991
 
@@ -1455,28 +1993,80 @@ module Net
1455
1993
  # rdoc-file=lib/net/http.rb
1456
1994
  # - request(req, body = nil) { |response| ... }
1457
1995
  # -->
1458
- # Sends an HTTPRequest object `req` to the HTTP server.
1996
+ # Sends the given request `req` to the server; forms the response into a
1997
+ # Net::HTTPResponse object.
1998
+ #
1999
+ # The given `req` must be an instance of a [subclass of
2000
+ # Net::HTTPRequest](rdoc-ref:Net::HTTPRequest@Request+Subclasses). Argument
2001
+ # `body` should be given only if needed for the request.
2002
+ #
2003
+ # With no block given, returns the response object:
2004
+ #
2005
+ # http = Net::HTTP.new(hostname)
2006
+ #
2007
+ # req = Net::HTTP::Get.new('/todos/1')
2008
+ # http.request(req)
2009
+ # # => #<Net::HTTPOK 200 OK readbody=true>
1459
2010
  #
1460
- # If `req` is a Net::HTTP::Post or Net::HTTP::Put request containing data, the
1461
- # data is also sent. Providing data for a Net::HTTP::Head or Net::HTTP::Get
1462
- # request results in an ArgumentError.
2011
+ # req = Net::HTTP::Post.new('/todos')
2012
+ # http.request(req, 'xyzzy')
2013
+ # # => #<Net::HTTPCreated 201 Created readbody=true>
1463
2014
  #
1464
- # Returns an HTTPResponse object.
2015
+ # With a block given, calls the block with the response and returns the
2016
+ # response:
1465
2017
  #
1466
- # When called with a block, passes an HTTPResponse object to the block. The body
1467
- # of the response will not have been read yet; the block can process it using
1468
- # HTTPResponse#read_body, if desired.
2018
+ # req = Net::HTTP::Get.new('/todos/1')
2019
+ # http.request(req) do |res|
2020
+ # p res
2021
+ # end # => #<Net::HTTPOK 200 OK readbody=true>
2022
+ #
2023
+ # Output:
1469
2024
  #
1470
- # This method never raises Net::* exceptions.
2025
+ # #<Net::HTTPOK 200 OK readbody=false>
1471
2026
  #
1472
2027
  def request: (Net::HTTPRequest req, ?String? body) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
1473
2028
  end
1474
2029
 
1475
2030
  # <!-- rdoc-file=lib/net/http/generic_request.rb -->
1476
- # HTTPGenericRequest is the parent of the Net::HTTPRequest class. Do not use
1477
- # this directly; use a subclass of Net::HTTPRequest.
2031
+ # HTTPGenericRequest is the parent of the Net::HTTPRequest class.
2032
+ #
2033
+ # Do not use this directly; instead, use a subclass of Net::HTTPRequest.
2034
+ #
2035
+ # ## About the Examples
2036
+ #
2037
+ # Examples here assume that `net/http` has been required (which also requires
2038
+ # `uri`):
2039
+ #
2040
+ # require 'net/http'
2041
+ #
2042
+ # Many code examples here use these example websites:
2043
+ #
2044
+ # * https://jsonplaceholder.typicode.com.
2045
+ # * http://example.com.
2046
+ #
2047
+ #
2048
+ # Some examples also assume these variables:
2049
+ #
2050
+ # uri = URI('https://jsonplaceholder.typicode.com/')
2051
+ # uri.freeze # Examples may not modify.
2052
+ # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
2053
+ # path = uri.path # => "/"
2054
+ # port = uri.port # => 443
1478
2055
  #
1479
- # Mixes in the Net::HTTPHeader module to provide easier access to HTTP headers.
2056
+ # So that example requests may be written as:
2057
+ #
2058
+ # Net::HTTP.get(uri)
2059
+ # Net::HTTP.get(hostname, '/index.html')
2060
+ # Net::HTTP.start(hostname) do |http|
2061
+ # http.get('/todos/1')
2062
+ # http.get('/todos/2')
2063
+ # end
2064
+ #
2065
+ # An example that needs a modified URI first duplicates `uri`, then modifies the
2066
+ # duplicate:
2067
+ #
2068
+ # _uri = uri.dup
2069
+ # _uri.path = '/todos/1'
1480
2070
  #
1481
2071
  class HTTPGenericRequest
1482
2072
  include Net::HTTPHeader
@@ -1488,15 +2078,43 @@ module Net
1488
2078
  #
1489
2079
  def initialize: (String m, boolish reqbody, boolish resbody, URI::Generic | String uri_or_path, ?Hash[String, untyped] initheader) -> Net::HTTP
1490
2080
 
2081
+ # <!-- rdoc-file=lib/net/http/generic_request.rb -->
2082
+ # Returns the string method name for the request:
2083
+ #
2084
+ # Net::HTTP::Get.new(uri).method # => "GET"
2085
+ # Net::HTTP::Post.new(uri).method # => "POST"
2086
+ #
1491
2087
  attr_reader method: String
1492
2088
 
2089
+ # <!-- rdoc-file=lib/net/http/generic_request.rb -->
2090
+ # Returns the string path for the request:
2091
+ #
2092
+ # Net::HTTP::Get.new(uri).path # => "/"
2093
+ # Net::HTTP::Post.new('example.com').path # => "example.com"
2094
+ #
1493
2095
  attr_reader path: String
1494
2096
 
2097
+ # <!-- rdoc-file=lib/net/http/generic_request.rb -->
2098
+ # Returns the URI object for the request, or `nil` if none:
2099
+ #
2100
+ # Net::HTTP::Get.new(uri).uri
2101
+ # # => #<URI::HTTPS https://jsonplaceholder.typicode.com/>
2102
+ # Net::HTTP::Get.new('example.com').uri # => nil
2103
+ #
1495
2104
  attr_reader uri: URI::Generic
1496
2105
 
1497
2106
  # <!-- rdoc-file=lib/net/http/generic_request.rb -->
1498
- # Automatically set to false if the user sets the Accept-Encoding header. This
1499
- # indicates they wish to handle Content-encoding in responses themselves.
2107
+ # Returns `false` if the request's header `'Accept-Encoding'` has been set
2108
+ # manually or deleted (indicating that the user intends to handle encoding in
2109
+ # the response), `true` otherwise:
2110
+ #
2111
+ # req = Net::HTTP::Get.new(uri) # => #<Net::HTTP::Get GET>
2112
+ # req['Accept-Encoding'] # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
2113
+ # req.decode_content # => true
2114
+ # req['Accept-Encoding'] = 'foo'
2115
+ # req.decode_content # => false
2116
+ # req.delete('Accept-Encoding')
2117
+ # req.decode_content # => false
1500
2118
  #
1501
2119
  attr_reader decode_content: bool
1502
2120
 
@@ -1504,6 +2122,9 @@ module Net
1504
2122
  # rdoc-file=lib/net/http/generic_request.rb
1505
2123
  # - inspect()
1506
2124
  # -->
2125
+ # Returns a string representation of the request:
2126
+ #
2127
+ # Net::HTTP::Post.new(uri).inspect # => "#<Net::HTTP::Post POST>"
1507
2128
  #
1508
2129
  def inspect: () -> String
1509
2130
 
@@ -1513,6 +2134,10 @@ module Net
1513
2134
  # rdoc-file=lib/net/http/generic_request.rb
1514
2135
  # - request_body_permitted?()
1515
2136
  # -->
2137
+ # Returns whether the request may have a body:
2138
+ #
2139
+ # Net::HTTP::Post.new(uri).request_body_permitted? # => true
2140
+ # Net::HTTP::Get.new(uri).request_body_permitted? # => false
1516
2141
  #
1517
2142
  def request_body_permitted?: () -> bool
1518
2143
 
@@ -1520,6 +2145,10 @@ module Net
1520
2145
  # rdoc-file=lib/net/http/generic_request.rb
1521
2146
  # - response_body_permitted?()
1522
2147
  # -->
2148
+ # Returns whether the response may have a body:
2149
+ #
2150
+ # Net::HTTP::Post.new(uri).response_body_permitted? # => true
2151
+ # Net::HTTP::Head.new(uri).response_body_permitted? # => false
1523
2152
  #
1524
2153
  def response_body_permitted?: () -> bool
1525
2154
 
@@ -1530,17 +2159,47 @@ module Net
1530
2159
  #
1531
2160
  def body_exist?: () -> bool
1532
2161
 
2162
+ # <!-- rdoc-file=lib/net/http/generic_request.rb -->
2163
+ # Returns the string body for the request, or `nil` if there is none:
2164
+ #
2165
+ # req = Net::HTTP::Post.new(uri)
2166
+ # req.body # => nil
2167
+ # req.body = '{"title": "foo","body": "bar","userId": 1}'
2168
+ # req.body # => "{\"title\": \"foo\",\"body\": \"bar\",\"userId\": 1}"
2169
+ # ----
1533
2170
  # <!--
1534
2171
  # rdoc-file=lib/net/http/generic_request.rb
1535
2172
  # - body=(str)
1536
2173
  # -->
2174
+ # Sets the body for the request:
2175
+ #
2176
+ # req = Net::HTTP::Post.new(uri)
2177
+ # req.body # => nil
2178
+ # req.body = '{"title": "foo","body": "bar","userId": 1}'
2179
+ # req.body # => "{\"title\": \"foo\",\"body\": \"bar\",\"userId\": 1}"
1537
2180
  #
1538
2181
  attr_accessor body: String?
1539
2182
 
2183
+ # <!-- rdoc-file=lib/net/http/generic_request.rb -->
2184
+ # Returns the body stream object for the request, or `nil` if there is none:
2185
+ #
2186
+ # req = Net::HTTP::Post.new(uri) # => #<Net::HTTP::Post POST>
2187
+ # req.body_stream # => nil
2188
+ # require 'stringio'
2189
+ # req.body_stream = StringIO.new('xyzzy') # => #<StringIO:0x0000027d1e5affa8>
2190
+ # req.body_stream # => #<StringIO:0x0000027d1e5affa8>
2191
+ # ----
1540
2192
  # <!--
1541
2193
  # rdoc-file=lib/net/http/generic_request.rb
1542
2194
  # - body_stream=(input)
1543
2195
  # -->
2196
+ # Sets the body stream for the request:
2197
+ #
2198
+ # req = Net::HTTP::Post.new(uri) # => #<Net::HTTP::Post POST>
2199
+ # req.body_stream # => nil
2200
+ # require 'stringio'
2201
+ # req.body_stream = StringIO.new('xyzzy') # => #<StringIO:0x0000027d1e5affa8>
2202
+ # req.body_stream # => #<StringIO:0x0000027d1e5affa8>
1544
2203
  #
1545
2204
  attr_accessor body_stream: untyped
1546
2205
  end
@@ -1594,9 +2253,10 @@ module Net
1594
2253
  #
1595
2254
  # Some examples also assume these variables:
1596
2255
  #
1597
- # uri = URI('https://jsonplaceholder.typicode.com')
2256
+ # uri = URI('https://jsonplaceholder.typicode.com/')
1598
2257
  # uri.freeze # Examples may not modify.
1599
2258
  # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
2259
+ # path = uri.path # => "/"
1600
2260
  # port = uri.port # => 443
1601
2261
  #
1602
2262
  # So that example requests may be written as:
@@ -2327,18 +2987,37 @@ module Net
2327
2987
  # rdoc-file=lib/net/http/header.rb
2328
2988
  # - set_form_data(params, sep = '&')
2329
2989
  # -->
2330
- # Set header fields and a body from HTML form data. `params` should be an Array
2331
- # of Arrays or a Hash containing HTML form data. Optional argument `sep` means
2332
- # data record separator.
2990
+ # Sets the request body to a URL-encoded string derived from argument `params`,
2991
+ # and sets request header field `'Content-Type'` to
2992
+ # `'application/x-www-form-urlencoded'`.
2333
2993
  #
2334
- # Values are URL encoded as necessary and the content-type is set to
2335
- # application/x-www-form-urlencoded
2994
+ # The resulting request is suitable for HTTP request `POST` or `PUT`.
2336
2995
  #
2337
- # Example:
2996
+ # Argument `params` must be suitable for use as argument `enum` to
2997
+ # [URI.encode_www_form](rdoc-ref:URI.encode_www_form).
2998
+ #
2999
+ # With only argument `params` given, sets the body to a URL-encoded string with
3000
+ # the default separator `'&'`:
3001
+ #
3002
+ # req = Net::HTTP::Post.new('example.com')
3003
+ #
3004
+ # req.set_form_data(q: 'ruby', lang: 'en')
3005
+ # req.body # => "q=ruby&lang=en"
3006
+ # req['Content-Type'] # => "application/x-www-form-urlencoded"
3007
+ #
3008
+ # req.set_form_data([['q', 'ruby'], ['lang', 'en']])
3009
+ # req.body # => "q=ruby&lang=en"
3010
+ #
3011
+ # req.set_form_data(q: ['ruby', 'perl'], lang: 'en')
3012
+ # req.body # => "q=ruby&q=perl&lang=en"
3013
+ #
3014
+ # req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']])
3015
+ # req.body # => "q=ruby&q=perl&lang=en"
3016
+ #
3017
+ # With string argument `sep` also given, uses that string as the separator:
2338
3018
  #
2339
- # http.form_data = {"q" => "ruby", "lang" => "en"}
2340
- # http.form_data = {"q" => ["ruby", "perl"], "lang" => "en"}
2341
- # http.set_form_data({"q" => "ruby", "lang" => "en"}, ';')
3019
+ # req.set_form_data({q: 'ruby', lang: 'en'}, '|')
3020
+ # req.body # => "q=ruby|lang=en"
2342
3021
  #
2343
3022
  # Net::HTTPHeader#form_data= is an alias for Net::HTTPHeader#set_form_data.
2344
3023
  #
@@ -2355,61 +3034,110 @@ module Net
2355
3034
  # rdoc-file=lib/net/http/header.rb
2356
3035
  # - set_form(params, enctype='application/x-www-form-urlencoded', formopt={})
2357
3036
  # -->
2358
- # Set an HTML form data set.
2359
- # `params`
2360
- # : The form data to set, which should be an enumerable. See below for more
2361
- # details.
2362
- # `enctype`
2363
- # : The content type to use to encode the form submission, which should be
2364
- # application/x-www-form-urlencoded or multipart/form-data.
2365
- # `formopt`
2366
- # : An options hash, supporting the following options:
2367
- # :boundary
2368
- # : The boundary of the multipart message. If not given, a random boundary
2369
- # will be used.
2370
- # :charset
2371
- # : The charset of the form submission. All field names and values of
2372
- # non-file fields should be encoded with this charset.
3037
+ # Stores form data to be used in a `POST` or `PUT` request.
2373
3038
  #
3039
+ # The form data given in `params` consists of zero or more fields; each field
3040
+ # is:
2374
3041
  #
3042
+ # * A scalar value.
3043
+ # * A name/value pair.
3044
+ # * An IO stream opened for reading.
2375
3045
  #
2376
- # Each item of params should respond to `each` and yield 2-3 arguments, or an
2377
- # array of 2-3 elements. The arguments yielded should be:
2378
3046
  #
2379
- # * The name of the field.
2380
- # * The value of the field, it should be a String or a File or IO-like.
2381
- # * An options hash, supporting the following options (used only for file
2382
- # uploads); entries:
3047
+ # Argument `params` should be an
3048
+ # [Enumerable](rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes) (method
3049
+ # `params.map` will be called), and is often an array or hash.
2383
3050
  #
2384
- # * `:filename`: The name of the file to use.
2385
- # * `:content_type`: The content type of the uploaded file.
3051
+ # First, we set up a request:
2386
3052
  #
3053
+ # _uri = uri.dup
3054
+ # _uri.path ='/posts'
3055
+ # req = Net::HTTP::Post.new(_uri)
2387
3056
  #
3057
+ # **Argument `params` As an Array**
2388
3058
  #
2389
- # Each item is a file field or a normal field. If `value` is a File object or
2390
- # the `opt` hash has a :filename key, the item is treated as a file field.
3059
+ # When `params` is an array, each of its elements is a subarray that defines a
3060
+ # field; the subarray may contain:
2391
3061
  #
2392
- # If Transfer-Encoding is set as chunked, this sends the request using chunked
2393
- # encoding. Because chunked encoding is HTTP/1.1 feature, you should confirm
2394
- # that the server supports HTTP/1.1 before using chunked encoding.
3062
+ # * One string:
2395
3063
  #
2396
- # Example:
3064
+ # req.set_form([['foo'], ['bar'], ['baz']])
3065
+ #
3066
+ # * Two strings:
3067
+ #
3068
+ # req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]])
3069
+ #
3070
+ # * When argument `enctype` (see below) is given as `'multipart/form-data'`:
3071
+ #
3072
+ # * A string name and an IO stream opened for reading:
3073
+ #
3074
+ # require 'stringio'
3075
+ # req.set_form([['file', StringIO.new('Ruby is cool.')]])
3076
+ #
3077
+ # * A string name, an IO stream opened for reading, and an options hash,
3078
+ # which may contain these entries:
3079
+ #
3080
+ # * `:filename`: The name of the file to use.
3081
+ # * `:content_type`: The content type of the uploaded file.
3082
+ #
3083
+ #
3084
+ # Example:
2397
3085
  #
2398
- # req.set_form([["q", "ruby"], ["lang", "en"]])
3086
+ # req.set_form([['file', file, {filename: "other-filename.foo"}]]
2399
3087
  #
2400
- # req.set_form({"f"=>File.open('/path/to/filename')},
2401
- # "multipart/form-data",
2402
- # charset: "UTF-8",
2403
- # )
2404
3088
  #
2405
- # req.set_form([["f",
2406
- # File.open('/path/to/filename.bar'),
2407
- # {filename: "other-filename.foo"}
2408
- # ]],
2409
- # "multipart/form-data",
2410
- # )
2411
3089
  #
2412
- # See also RFC 2388, RFC 2616, HTML 4.01, and HTML5
3090
+ # The various forms may be mixed:
3091
+ #
3092
+ # req.set_form(['foo', %w[bar 1], ['file', file]])
3093
+ #
3094
+ # **Argument `params` As a Hash**
3095
+ #
3096
+ # When `params` is a hash, each of its entries is a name/value pair that defines
3097
+ # a field:
3098
+ #
3099
+ # * The name is a string.
3100
+ # * The value may be:
3101
+ #
3102
+ # * `nil`.
3103
+ # * Another string.
3104
+ # * An IO stream opened for reading (only when argument `enctype` -- see
3105
+ # below -- is given as `'multipart/form-data'`).
3106
+ #
3107
+ #
3108
+ #
3109
+ # Examples:
3110
+ #
3111
+ # # Nil-valued fields.
3112
+ # req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil})
3113
+ #
3114
+ # # String-valued fields.
3115
+ # req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2})
3116
+ #
3117
+ # # IO-valued field.
3118
+ # require 'stringio'
3119
+ # req.set_form({'file' => StringIO.new('Ruby is cool.')})
3120
+ #
3121
+ # # Mixture of fields.
3122
+ # req.set_form({'foo' => nil, 'bar' => 1, 'file' => file})
3123
+ #
3124
+ # Optional argument `enctype` specifies the value to be given to field
3125
+ # `'Content-Type'`, and must be one of:
3126
+ #
3127
+ # * `'application/x-www-form-urlencoded'` (the default).
3128
+ # * `'multipart/form-data'`; see [RFC
3129
+ # 7578](https://www.rfc-editor.org/rfc/rfc7578).
3130
+ #
3131
+ #
3132
+ # Optional argument `formopt` is a hash of options (applicable only when
3133
+ # argument `enctype` is `'multipart/form-data'`) that may include the following
3134
+ # entries:
3135
+ #
3136
+ # * `:boundary`: The value is the boundary string for the multipart message.
3137
+ # If not given, the boundary is a random string. See
3138
+ # [Boundary](https://www.rfc-editor.org/rfc/rfc7578#section-4.1).
3139
+ # * `:charset`: Value is the character set for the form submission. Field
3140
+ # names and values of non-file fields should be encoded with this charset.
2413
3141
  #
2414
3142
  def set_form: (Hash[untyped, untyped] params, ?String enctype, ?Hash[untyped, untyped] formopt) -> void
2415
3143
 
@@ -2417,7 +3145,12 @@ module Net
2417
3145
  # rdoc-file=lib/net/http/header.rb
2418
3146
  # - basic_auth(account, password)
2419
3147
  # -->
2420
- # Set the Authorization: header for "Basic" authorization.
3148
+ # Sets header `'Authorization'` using the given `account` and `password`
3149
+ # strings:
3150
+ #
3151
+ # req.basic_auth('my_account', 'my_password')
3152
+ # req['Authorization']
3153
+ # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
2421
3154
  #
2422
3155
  def basic_auth: (String account, String password) -> void
2423
3156
 
@@ -2425,7 +3158,12 @@ module Net
2425
3158
  # rdoc-file=lib/net/http/header.rb
2426
3159
  # - proxy_basic_auth(account, password)
2427
3160
  # -->
2428
- # Set Proxy-Authorization: header for "Basic" authorization.
3161
+ # Sets header `'Proxy-Authorization'` using the given `account` and `password`
3162
+ # strings:
3163
+ #
3164
+ # req.proxy_basic_auth('my_account', 'my_password')
3165
+ # req['Proxy-Authorization']
3166
+ # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
2429
3167
  #
2430
3168
  def proxy_basic_auth: (String account, String password) -> void
2431
3169
 
@@ -2444,6 +3182,7 @@ module Net
2444
3182
  # rdoc-file=lib/net/http/header.rb
2445
3183
  # - connection_close?()
2446
3184
  # -->
3185
+ # Returns whether the HTTP session is to be closed.
2447
3186
  #
2448
3187
  def connection_close?: () -> bool
2449
3188
 
@@ -2451,15 +3190,70 @@ module Net
2451
3190
  # rdoc-file=lib/net/http/header.rb
2452
3191
  # - connection_keep_alive?()
2453
3192
  # -->
3193
+ # Returns whether the HTTP session is to be kept alive.
2454
3194
  #
2455
3195
  def connection_keep_alive?: () -> bool
2456
3196
  end
2457
3197
 
2458
3198
  # <!-- rdoc-file=lib/net/http/request.rb -->
2459
- # This class is the base class for Net::HTTP request classes; it wraps together
2460
- # the request path and the request headers.
3199
+ # This class is the base class for Net::HTTP request classes. The class should
3200
+ # not be used directly; instead you should use its subclasses, listed below.
3201
+ #
3202
+ # ## Creating a Request
2461
3203
  #
2462
- # The class should not be used directly; instead you should use its subclasses.
3204
+ # An request object may be created with either a URI or a string hostname:
3205
+ #
3206
+ # require 'net/http'
3207
+ # uri = URI('https://jsonplaceholder.typicode.com/')
3208
+ # req = Net::HTTP::Get.new(uri) # => #<Net::HTTP::Get GET>
3209
+ # req = Net::HTTP::Get.new(uri.hostname) # => #<Net::HTTP::Get GET>
3210
+ #
3211
+ # And with any of the subclasses:
3212
+ #
3213
+ # req = Net::HTTP::Head.new(uri) # => #<Net::HTTP::Head HEAD>
3214
+ # req = Net::HTTP::Post.new(uri) # => #<Net::HTTP::Post POST>
3215
+ # req = Net::HTTP::Put.new(uri) # => #<Net::HTTP::Put PUT>
3216
+ # # ...
3217
+ #
3218
+ # The new instance is suitable for use as the argument to Net::HTTP#request.
3219
+ #
3220
+ # ## Request Headers
3221
+ #
3222
+ # A new request object has these header fields by default:
3223
+ #
3224
+ # req.to_hash
3225
+ # # =>
3226
+ # {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
3227
+ # "accept"=>["*/*"],
3228
+ # "user-agent"=>["Ruby"],
3229
+ # "host"=>["jsonplaceholder.typicode.com"]}
3230
+ #
3231
+ # See:
3232
+ #
3233
+ # * [Request header
3234
+ # Accept-Encoding](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#
3235
+ # Accept-Encoding) and [Compression and
3236
+ # Decompression](rdoc-ref:Net::HTTP@Compression+and+Decompression).
3237
+ # * [Request header
3238
+ # Accept](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#accept-re
3239
+ # quest-header).
3240
+ # * [Request header
3241
+ # User-Agent](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#user-
3242
+ # agent-request-header).
3243
+ # * [Request header
3244
+ # Host](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#host-reques
3245
+ # t-header).
3246
+ #
3247
+ #
3248
+ # You can add headers or override default headers:
3249
+ #
3250
+ # # res = Net::HTTP::Get.new(uri, {'foo' => '0', 'bar' => '1'})
3251
+ #
3252
+ # This class (and therefore its subclasses) also includes (indirectly) module
3253
+ # Net::HTTPHeader, which gives access to its [methods for setting
3254
+ # headers](rdoc-ref:Net::HTTPHeader@Setters).
3255
+ #
3256
+ # ## Request Subclasses
2463
3257
  #
2464
3258
  # Subclasses for HTTP requests:
2465
3259
  #
@@ -2511,6 +3305,8 @@ module Net
2511
3305
  # http.request(req)
2512
3306
  # end
2513
3307
  #
3308
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3309
+ #
2514
3310
  # Properties:
2515
3311
  #
2516
3312
  # * Request body: optional.
@@ -2549,6 +3345,8 @@ module Net
2549
3345
  # http.request(req)
2550
3346
  # end
2551
3347
  #
3348
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3349
+ #
2552
3350
  # Properties:
2553
3351
  #
2554
3352
  # * Request body: optional.
@@ -2589,6 +3387,8 @@ module Net
2589
3387
  # http.request(req)
2590
3388
  # end
2591
3389
  #
3390
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3391
+ #
2592
3392
  # Properties:
2593
3393
  #
2594
3394
  # * Request body: yes.
@@ -2630,6 +3430,8 @@ module Net
2630
3430
  # http.request(req)
2631
3431
  # end
2632
3432
  #
3433
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3434
+ #
2633
3435
  # Properties:
2634
3436
  #
2635
3437
  # * Request body: yes.
@@ -2663,6 +3465,8 @@ module Net
2663
3465
  # http.request(req)
2664
3466
  # end
2665
3467
  #
3468
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3469
+ #
2666
3470
  # Properties:
2667
3471
  #
2668
3472
  # * Request body: optional.
@@ -2700,6 +3504,8 @@ module Net
2700
3504
  # http.request(req)
2701
3505
  # end
2702
3506
  #
3507
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3508
+ #
2703
3509
  # Properties:
2704
3510
  #
2705
3511
  # * Request body: optional.
@@ -2737,6 +3543,8 @@ module Net
2737
3543
  # http.request(req)
2738
3544
  # end
2739
3545
  #
3546
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3547
+ #
2740
3548
  # Properties:
2741
3549
  #
2742
3550
  # * Request body: no.
@@ -2777,6 +3585,8 @@ module Net
2777
3585
  # http.request(req)
2778
3586
  # end
2779
3587
  #
3588
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3589
+ #
2780
3590
  # Properties:
2781
3591
  #
2782
3592
  # * Request body: yes.
@@ -2813,6 +3623,8 @@ module Net
2813
3623
  # http.request(req)
2814
3624
  # end
2815
3625
  #
3626
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3627
+ #
2816
3628
  # Related:
2817
3629
  #
2818
3630
  # * Net::HTTP#propfind: sends `PROPFIND` request, returns response object.
@@ -2837,6 +3649,8 @@ module Net
2837
3649
  # http.request(req)
2838
3650
  # end
2839
3651
  #
3652
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3653
+ #
2840
3654
  # Related:
2841
3655
  #
2842
3656
  # * Net::HTTP#proppatch: sends `PROPPATCH` request, returns response object.
@@ -2861,6 +3675,8 @@ module Net
2861
3675
  # http.request(req)
2862
3676
  # end
2863
3677
  #
3678
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3679
+ #
2864
3680
  # Related:
2865
3681
  #
2866
3682
  # * Net::HTTP#mkcol: sends `MKCOL` request, returns response object.
@@ -2885,6 +3701,8 @@ module Net
2885
3701
  # http.request(req)
2886
3702
  # end
2887
3703
  #
3704
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3705
+ #
2888
3706
  # Related:
2889
3707
  #
2890
3708
  # * Net::HTTP#copy: sends `COPY` request, returns response object.
@@ -2909,6 +3727,8 @@ module Net
2909
3727
  # http.request(req)
2910
3728
  # end
2911
3729
  #
3730
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3731
+ #
2912
3732
  # Related:
2913
3733
  #
2914
3734
  # * Net::HTTP#move: sends `MOVE` request, returns response object.
@@ -2933,6 +3753,8 @@ module Net
2933
3753
  # http.request(req)
2934
3754
  # end
2935
3755
  #
3756
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3757
+ #
2936
3758
  # Related:
2937
3759
  #
2938
3760
  # * Net::HTTP#lock: sends `LOCK` request, returns response object.
@@ -2957,6 +3779,8 @@ module Net
2957
3779
  # http.request(req)
2958
3780
  # end
2959
3781
  #
3782
+ # See [Request Headers](rdoc-ref:Net::HTTPRequest@Request+Headers).
3783
+ #
2960
3784
  # Related:
2961
3785
  #
2962
3786
  # * Net::HTTP#unlock: sends `UNLOCK` request, returns response object.
@@ -2970,7 +3794,7 @@ module Net
2970
3794
  end
2971
3795
 
2972
3796
  # <!-- rdoc-file=lib/net/http/response.rb -->
2973
- # This class is the base class for Net::HTTP request classes.
3797
+ # This class is the base class for Net::HTTP response classes.
2974
3798
  #
2975
3799
  # ## About the Examples
2976
3800
  #
@@ -2987,9 +3811,10 @@ module Net
2987
3811
  #
2988
3812
  # Some examples also assume these variables:
2989
3813
  #
2990
- # uri = URI('https://jsonplaceholder.typicode.com')
3814
+ # uri = URI('https://jsonplaceholder.typicode.com/')
2991
3815
  # uri.freeze # Examples may not modify.
2992
3816
  # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
3817
+ # path = uri.path # => "/"
2993
3818
  # port = uri.port # => 443
2994
3819
  #
2995
3820
  # So that example requests may be written as:
@@ -3254,19 +4079,20 @@ module Net
3254
4079
  # rdoc-file=lib/net/http/response.rb
3255
4080
  # - body()
3256
4081
  # -->
3257
- # Returns the full entity body.
4082
+ # Returns the string response body; note that repeated calls for the unmodified
4083
+ # body return a cached string:
3258
4084
  #
3259
- # Calling this method a second or subsequent time will return the string already
3260
- # read.
4085
+ # path = '/todos/1'
4086
+ # Net::HTTP.start(hostname) do |http|
4087
+ # res = http.get(path)
4088
+ # p res.body
4089
+ # p http.head(path).body # No body.
4090
+ # end
3261
4091
  #
3262
- # http.request_get('/index.html') {|res|
3263
- # puts res.body
3264
- # }
4092
+ # Output:
3265
4093
  #
3266
- # http.request_get('/index.html') {|res|
3267
- # p res.body.object_id # 538149362
3268
- # p res.body.object_id # 538149362
3269
- # }
4094
+ # "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}"
4095
+ # nil
3270
4096
  #
3271
4097
  def body: () -> String
3272
4098
 
@@ -3274,8 +4100,7 @@ module Net
3274
4100
  # rdoc-file=lib/net/http/response.rb
3275
4101
  # - body=(value)
3276
4102
  # -->
3277
- # Because it may be necessary to modify the body, Eg, decompression this method
3278
- # facilitates that.
4103
+ # Sets the body of the response to the given value.
3279
4104
  #
3280
4105
  def body=: (untyped value) -> void
3281
4106
 
@@ -3387,6 +4212,9 @@ module Net
3387
4212
  # A `Continue` response indicates that the server has received the request
3388
4213
  # headers.
3389
4214
  #
4215
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4216
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4217
+ #
3390
4218
  # References:
3391
4219
  #
3392
4220
  # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100).
@@ -3403,6 +4231,9 @@ module Net
3403
4231
  # The <tt>Switching Protocol<tt> response indicates that the server has received
3404
4232
  # a request to switch protocols, and has agreed to do so.
3405
4233
  #
4234
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4235
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4236
+ #
3406
4237
  # References:
3407
4238
  #
3408
4239
  # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/101).
@@ -3421,8 +4252,12 @@ module Net
3421
4252
  # The `Processing` response indicates that the server has received and is
3422
4253
  # processing the request, but no response is available yet.
3423
4254
  #
4255
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4256
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4257
+ #
3424
4258
  # References:
3425
4259
  #
4260
+ # * [RFC 2518](https://www.rfc-editor.org/rfc/rfc2518#section-10.1).
3426
4261
  # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#102).
3427
4262
  #
3428
4263
  class HTTPProcessing < HTTPInformation
@@ -3436,9 +4271,13 @@ module Net
3436
4271
  # request, and contains certain headers; the final response is not available
3437
4272
  # yet.
3438
4273
  #
4274
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4275
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4276
+ #
3439
4277
  # References:
3440
4278
  #
3441
4279
  # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103).
4280
+ # * [RFC 8297](https://www.rfc-editor.org/rfc/rfc8297.html#section-2).
3442
4281
  # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#103).
3443
4282
  #
3444
4283
  class HTTPEarlyHints < HTTPInformation
@@ -3449,8 +4288,16 @@ module Net
3449
4288
  # Response class for `OK` responses (status code 200).
3450
4289
  #
3451
4290
  # The `OK` response indicates that the server has received a request and has
3452
- # responded successfully. See [200
3453
- # OK](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200).
4291
+ # responded successfully.
4292
+ #
4293
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4294
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4295
+ #
4296
+ # References:
4297
+ #
4298
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200).
4299
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok).
4300
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200).
3454
4301
  #
3455
4302
  class HTTPOK < HTTPSuccess
3456
4303
  HAS_BODY: bool
@@ -3460,8 +4307,16 @@ module Net
3460
4307
  # Response class for `Created` responses (status code 201).
3461
4308
  #
3462
4309
  # The `Created` response indicates that the server has received and has
3463
- # fulfilled a request to create a new resource. See [201
3464
- # Created](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#201).
4310
+ # fulfilled a request to create a new resource.
4311
+ #
4312
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4313
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4314
+ #
4315
+ # References:
4316
+ #
4317
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201).
4318
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-201-created).
4319
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#201).
3465
4320
  #
3466
4321
  class HTTPCreated < HTTPSuccess
3467
4322
  HAS_BODY: bool
@@ -3471,8 +4326,16 @@ module Net
3471
4326
  # Response class for `Accepted` responses (status code 202).
3472
4327
  #
3473
4328
  # The `Accepted` response indicates that the server has received and is
3474
- # processing a request, but the processing has not yet been completed. See [202
3475
- # Accepted](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#202).
4329
+ # processing a request, but the processing has not yet been completed.
4330
+ #
4331
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4332
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4333
+ #
4334
+ # References:
4335
+ #
4336
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202).
4337
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-202-accepted).
4338
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#202).
3476
4339
  #
3477
4340
  class HTTPAccepted < HTTPSuccess
3478
4341
  HAS_BODY: bool
@@ -3485,8 +4348,17 @@ module Net
3485
4348
  # The `Non-Authoritative Information` response indicates that the server is a
3486
4349
  # transforming proxy (such as a Web accelerator) that received a 200 OK response
3487
4350
  # from its origin, and is returning a modified version of the origin's response.
3488
- # See [203 Non-Authoritative
3489
- # Information](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#203).
4351
+ #
4352
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4353
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4354
+ #
4355
+ # References:
4356
+ #
4357
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/203).
4358
+ # * [RFC
4359
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-203-non-authoritati
4360
+ # ve-infor).
4361
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#203).
3490
4362
  #
3491
4363
  class HTTPNonAuthoritativeInformation < HTTPSuccess
3492
4364
  HAS_BODY: bool
@@ -3496,8 +4368,17 @@ module Net
3496
4368
  # Response class for `No Content` responses (status code 204).
3497
4369
  #
3498
4370
  # The `No Content` response indicates that the server successfully processed the
3499
- # request, and is not returning any content. See [204 No
3500
- # Content](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204).
4371
+ # request, and is not returning any content.
4372
+ #
4373
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4374
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4375
+ #
4376
+ # References:
4377
+ #
4378
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204).
4379
+ # * [RFC
4380
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-204-no-content).
4381
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204).
3501
4382
  #
3502
4383
  class HTTPNoContent < HTTPSuccess
3503
4384
  HAS_BODY: bool
@@ -3508,8 +4389,17 @@ module Net
3508
4389
  #
3509
4390
  # The `Reset Content` response indicates that the server successfully processed
3510
4391
  # the request, asks that the client reset its document view, and is not
3511
- # returning any content. See [205 Reset
3512
- # Content](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#205).
4392
+ # returning any content.
4393
+ #
4394
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4395
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4396
+ #
4397
+ # References:
4398
+ #
4399
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/205).
4400
+ # * [RFC
4401
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-205-reset-content).
4402
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#205).
3513
4403
  #
3514
4404
  class HTTPResetContent < HTTPSuccess
3515
4405
  HAS_BODY: bool
@@ -3519,9 +4409,18 @@ module Net
3519
4409
  # Response class for `Partial Content` responses (status code 206).
3520
4410
  #
3521
4411
  # The `Partial Content` response indicates that the server is delivering only
3522
- # part of the resource (byte serving) due to a Range header in the request. See
3523
- # [206 Partial
3524
- # Content](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#206).
4412
+ # part of the resource (byte serving) due to a Range header in the request.
4413
+ #
4414
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4415
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4416
+ #
4417
+ # References:
4418
+ #
4419
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206).
4420
+ # * [RFC
4421
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-206-partial-content
4422
+ # ).
4423
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#206).
3525
4424
  #
3526
4425
  class HTTPPartialContent < HTTPSuccess
3527
4426
  HAS_BODY: bool
@@ -3532,8 +4431,15 @@ module Net
3532
4431
  #
3533
4432
  # The `Multi-Status (WebDAV)` response indicates that the server has received
3534
4433
  # the request, and that the message body can contain a number of separate
3535
- # response codes. See [207 Multi-Status
3536
- # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#207).
4434
+ # response codes.
4435
+ #
4436
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4437
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4438
+ #
4439
+ # References:
4440
+ #
4441
+ # * [RFC 4818](https://www.rfc-editor.org/rfc/rfc4918#section-11.1).
4442
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#207).
3537
4443
  #
3538
4444
  class HTTPMultiStatus < HTTPSuccess
3539
4445
  HAS_BODY: bool
@@ -3545,8 +4451,15 @@ module Net
3545
4451
  # The `Already Reported (WebDAV)` response indicates that the server has
3546
4452
  # received the request, and that the members of a DAV binding have already been
3547
4453
  # enumerated in a preceding part of the (multi-status) response, and are not
3548
- # being included again. See [208 Already Reported
3549
- # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208).
4454
+ # being included again.
4455
+ #
4456
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4457
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4458
+ #
4459
+ # References:
4460
+ #
4461
+ # * [RFC 5842](https://www.rfc-editor.org/rfc/rfc5842.html#section-7.1).
4462
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208).
3550
4463
  #
3551
4464
  class HTTPAlreadyReported < HTTPSuccess
3552
4465
  HAS_BODY: bool
@@ -3557,8 +4470,15 @@ module Net
3557
4470
  #
3558
4471
  # The `IM Used` response indicates that the server has fulfilled a request for
3559
4472
  # the resource, and the response is a representation of the result of one or
3560
- # more instance-manipulations applied to the current instance. See [226 IM
3561
- # Used](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#226).
4473
+ # more instance-manipulations applied to the current instance.
4474
+ #
4475
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4476
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4477
+ #
4478
+ # References:
4479
+ #
4480
+ # * [RFC 3229](https://www.rfc-editor.org/rfc/rfc3229.html#section-10.4.1).
4481
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#226).
3562
4482
  #
3563
4483
  class HTTPIMUsed < HTTPSuccess
3564
4484
  HAS_BODY: bool
@@ -3568,8 +4488,18 @@ module Net
3568
4488
  # Response class for `Multiple Choices` responses (status code 300).
3569
4489
  #
3570
4490
  # The `Multiple Choices` response indicates that the server offers multiple
3571
- # options for the resource from which the client may choose. See [300 Multiple
3572
- # Choices](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300).
4491
+ # options for the resource from which the client may choose.
4492
+ #
4493
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4494
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4495
+ #
4496
+ # References:
4497
+ #
4498
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/300).
4499
+ # * [RFC
4500
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-300-multiple-choice
4501
+ # s).
4502
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300).
3573
4503
  #
3574
4504
  class HTTPMultipleChoices < HTTPRedirection
3575
4505
  HAS_BODY: bool
@@ -3579,8 +4509,18 @@ module Net
3579
4509
  # Response class for `Multiple Choices` responses (status code 300).
3580
4510
  #
3581
4511
  # The `Multiple Choices` response indicates that the server offers multiple
3582
- # options for the resource from which the client may choose. See [300 Multiple
3583
- # Choices](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300).
4512
+ # options for the resource from which the client may choose.
4513
+ #
4514
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4515
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4516
+ #
4517
+ # References:
4518
+ #
4519
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/300).
4520
+ # * [RFC
4521
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-300-multiple-choice
4522
+ # s).
4523
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300).
3584
4524
  #
3585
4525
  HTTPMultipleChoice: HTTPMultipleChoices
3586
4526
 
@@ -3588,8 +4528,18 @@ module Net
3588
4528
  # Response class for `Moved Permanently` responses (status code 301).
3589
4529
  #
3590
4530
  # The `Moved Permanently` response indicates that links or records returning
3591
- # this response should be updated to use the given URL. See [301 Moved
3592
- # Permanently](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#301).
4531
+ # this response should be updated to use the given URL.
4532
+ #
4533
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4534
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4535
+ #
4536
+ # References:
4537
+ #
4538
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301).
4539
+ # * [RFC
4540
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-301-moved-permanent
4541
+ # ly).
4542
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#301).
3593
4543
  #
3594
4544
  class HTTPMovedPermanently < HTTPRedirection
3595
4545
  HAS_BODY: bool
@@ -3599,8 +4549,16 @@ module Net
3599
4549
  # Response class for `Found` responses (status code 302).
3600
4550
  #
3601
4551
  # The `Found` response indicates that the client should look at (browse to)
3602
- # another URL. See [302
3603
- # Found](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#302).
4552
+ # another URL.
4553
+ #
4554
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4555
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4556
+ #
4557
+ # References:
4558
+ #
4559
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
4560
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-302-found).
4561
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#302).
3604
4562
  #
3605
4563
  class HTTPFound < HTTPRedirection
3606
4564
  HAS_BODY: bool
@@ -3610,8 +4568,17 @@ module Net
3610
4568
  # Response class for `See Other` responses (status code 303).
3611
4569
  #
3612
4570
  # The response to the request can be found under another URI using the GET
3613
- # method. See [303 See
3614
- # Other](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#303).
4571
+ # method.
4572
+ #
4573
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4574
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4575
+ #
4576
+ # References:
4577
+ #
4578
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303).
4579
+ # * [RFC
4580
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-303-see-other).
4581
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#303).
3615
4582
  #
3616
4583
  class HTTPSeeOther < HTTPRedirection
3617
4584
  HAS_BODY: bool
@@ -3621,8 +4588,17 @@ module Net
3621
4588
  # Response class for `Not Modified` responses (status code 304).
3622
4589
  #
3623
4590
  # Indicates that the resource has not been modified since the version specified
3624
- # by the request headers. See [304 Not
3625
- # Modified](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#304).
4591
+ # by the request headers.
4592
+ #
4593
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4594
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4595
+ #
4596
+ # References:
4597
+ #
4598
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304).
4599
+ # * [RFC
4600
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-304-not-modified).
4601
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#304).
3626
4602
  #
3627
4603
  class HTTPNotModified < HTTPRedirection
3628
4604
  HAS_BODY: bool
@@ -3632,8 +4608,16 @@ module Net
3632
4608
  # Response class for `Use Proxy` responses (status code 305).
3633
4609
  #
3634
4610
  # The requested resource is available only through a proxy, whose address is
3635
- # provided in the response. See [305 Use
3636
- # Proxy](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#305).
4611
+ # provided in the response.
4612
+ #
4613
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4614
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4615
+ #
4616
+ # References:
4617
+ #
4618
+ # * [RFC
4619
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-305-use-proxy).
4620
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#305).
3637
4621
  #
3638
4622
  class HTTPUseProxy < HTTPRedirection
3639
4623
  HAS_BODY: bool
@@ -3643,8 +4627,18 @@ module Net
3643
4627
  # Response class for `Temporary Redirect` responses (status code 307).
3644
4628
  #
3645
4629
  # The request should be repeated with another URI; however, future requests
3646
- # should still use the original URI. See [307 Temporary
3647
- # Redirect](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#307).
4630
+ # should still use the original URI.
4631
+ #
4632
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4633
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4634
+ #
4635
+ # References:
4636
+ #
4637
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307).
4638
+ # * [RFC
4639
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-307-temporary-redir
4640
+ # ect).
4641
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#307).
3648
4642
  #
3649
4643
  class HTTPTemporaryRedirect < HTTPRedirection
3650
4644
  HAS_BODY: bool
@@ -3653,9 +4647,18 @@ module Net
3653
4647
  # <!-- rdoc-file=lib/net/http/responses.rb -->
3654
4648
  # Response class for `Permanent Redirect` responses (status code 308).
3655
4649
  #
3656
- # This and all future requests should be directed to the given URI. See [308
3657
- # Permanent
3658
- # Redirect](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#308).
4650
+ # This and all future requests should be directed to the given URI.
4651
+ #
4652
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4653
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4654
+ #
4655
+ # References:
4656
+ #
4657
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308).
4658
+ # * [RFC
4659
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-308-permanent-redir
4660
+ # ect).
4661
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#308).
3659
4662
  #
3660
4663
  class HTTPPermanentRedirect < HTTPRedirection
3661
4664
  HAS_BODY: bool
@@ -3665,8 +4668,17 @@ module Net
3665
4668
  # Response class for `Bad Request` responses (status code 400).
3666
4669
  #
3667
4670
  # The server cannot or will not process the request due to an apparent client
3668
- # error. See [400 Bad
3669
- # Request](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#400).
4671
+ # error.
4672
+ #
4673
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4674
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4675
+ #
4676
+ # References:
4677
+ #
4678
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400).
4679
+ # * [RFC
4680
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-400-bad-request).
4681
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#400).
3670
4682
  #
3671
4683
  class HTTPBadRequest < HTTPClientError
3672
4684
  HAS_BODY: bool
@@ -3675,8 +4687,17 @@ module Net
3675
4687
  # <!-- rdoc-file=lib/net/http/responses.rb -->
3676
4688
  # Response class for `Unauthorized` responses (status code 401).
3677
4689
  #
3678
- # Authentication is required, but either was not provided or failed. See [401
3679
- # Unauthorized](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#401).
4690
+ # Authentication is required, but either was not provided or failed.
4691
+ #
4692
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4693
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4694
+ #
4695
+ # References:
4696
+ #
4697
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401).
4698
+ # * [RFC
4699
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-401-unauthorized).
4700
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#401).
3680
4701
  #
3681
4702
  class HTTPUnauthorized < HTTPClientError
3682
4703
  HAS_BODY: bool
@@ -3685,8 +4706,18 @@ module Net
3685
4706
  # <!-- rdoc-file=lib/net/http/responses.rb -->
3686
4707
  # Response class for `Payment Required` responses (status code 402).
3687
4708
  #
3688
- # Reserved for future use. See [402 Payment
3689
- # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#402).
4709
+ # Reserved for future use.
4710
+ #
4711
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4712
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4713
+ #
4714
+ # References:
4715
+ #
4716
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402).
4717
+ # * [RFC
4718
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-402-payment-require
4719
+ # d).
4720
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#402).
3690
4721
  #
3691
4722
  class HTTPPaymentRequired < HTTPClientError
3692
4723
  HAS_BODY: bool
@@ -3696,8 +4727,17 @@ module Net
3696
4727
  # Response class for `Forbidden` responses (status code 403).
3697
4728
  #
3698
4729
  # The request contained valid data and was understood by the server, but the
3699
- # server is refusing action. See [403
3700
- # Forbidden](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#403).
4730
+ # server is refusing action.
4731
+ #
4732
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4733
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4734
+ #
4735
+ # References:
4736
+ #
4737
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403).
4738
+ # * [RFC
4739
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-403-forbidden).
4740
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#403).
3701
4741
  #
3702
4742
  class HTTPForbidden < HTTPClientError
3703
4743
  HAS_BODY: bool
@@ -3707,8 +4747,16 @@ module Net
3707
4747
  # Response class for `Not Found` responses (status code 404).
3708
4748
  #
3709
4749
  # The requested resource could not be found but may be available in the future.
3710
- # See [404 Not
3711
- # Found](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404).
4750
+ #
4751
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4752
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4753
+ #
4754
+ # References:
4755
+ #
4756
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404).
4757
+ # * [RFC
4758
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found).
4759
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404).
3712
4760
  #
3713
4761
  class HTTPNotFound < HTTPClientError
3714
4762
  HAS_BODY: bool
@@ -3717,9 +4765,18 @@ module Net
3717
4765
  # <!-- rdoc-file=lib/net/http/responses.rb -->
3718
4766
  # Response class for `Method Not Allowed` responses (status code 405).
3719
4767
  #
3720
- # The request method is not supported for the requested resource. See [405
3721
- # Method Not
3722
- # Allowed](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405).
4768
+ # The request method is not supported for the requested resource.
4769
+ #
4770
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4771
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4772
+ #
4773
+ # References:
4774
+ #
4775
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405).
4776
+ # * [RFC
4777
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-405-method-not-allo
4778
+ # wed).
4779
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405).
3723
4780
  #
3724
4781
  class HTTPMethodNotAllowed < HTTPClientError
3725
4782
  HAS_BODY: bool
@@ -3729,8 +4786,18 @@ module Net
3729
4786
  # Response class for `Not Acceptable` responses (status code 406).
3730
4787
  #
3731
4788
  # The requested resource is capable of generating only content that not
3732
- # acceptable according to the Accept headers sent in the request. See [406 Not
3733
- # Acceptable](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#406).
4789
+ # acceptable according to the Accept headers sent in the request.
4790
+ #
4791
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4792
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4793
+ #
4794
+ # References:
4795
+ #
4796
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406).
4797
+ # * [RFC
4798
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-406-not-acceptable)
4799
+ # .
4800
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#406).
3734
4801
  #
3735
4802
  class HTTPNotAcceptable < HTTPClientError
3736
4803
  HAS_BODY: bool
@@ -3740,9 +4807,18 @@ module Net
3740
4807
  # Response class for `Proxy Authentication Required` responses (status code
3741
4808
  # 407).
3742
4809
  #
3743
- # The client must first authenticate itself with the proxy. See [407 Proxy
3744
- # Authentication
3745
- # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#407).
4810
+ # The client must first authenticate itself with the proxy.
4811
+ #
4812
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4813
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4814
+ #
4815
+ # References:
4816
+ #
4817
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407).
4818
+ # * [RFC
4819
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-407-proxy-authentic
4820
+ # ation-re).
4821
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#407).
3746
4822
  #
3747
4823
  class HTTPProxyAuthenticationRequired < HTTPClientError
3748
4824
  HAS_BODY: bool
@@ -3751,8 +4827,18 @@ module Net
3751
4827
  # <!-- rdoc-file=lib/net/http/responses.rb -->
3752
4828
  # Response class for `Request Timeout` responses (status code 408).
3753
4829
  #
3754
- # The server timed out waiting for the request. See [408 Request
3755
- # Timeout](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#408).
4830
+ # The server timed out waiting for the request.
4831
+ #
4832
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4833
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4834
+ #
4835
+ # References:
4836
+ #
4837
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408).
4838
+ # * [RFC
4839
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-408-request-timeout
4840
+ # ).
4841
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#408).
3756
4842
  #
3757
4843
  class HTTPRequestTimeout < HTTPClientError
3758
4844
  HAS_BODY: bool
@@ -3762,8 +4848,16 @@ module Net
3762
4848
  # Response class for `Conflict` responses (status code 409).
3763
4849
  #
3764
4850
  # The request could not be processed because of conflict in the current state of
3765
- # the resource. See [409
3766
- # Conflict](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#409).
4851
+ # the resource.
4852
+ #
4853
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4854
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4855
+ #
4856
+ # References:
4857
+ #
4858
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409).
4859
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-409-conflict).
4860
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#409).
3767
4861
  #
3768
4862
  class HTTPConflict < HTTPClientError
3769
4863
  HAS_BODY: bool
@@ -3773,8 +4867,16 @@ module Net
3773
4867
  # Response class for `Gone` responses (status code 410).
3774
4868
  #
3775
4869
  # The resource requested was previously in use but is no longer available and
3776
- # will not be available again. See [410
3777
- # Gone](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#410).
4870
+ # will not be available again.
4871
+ #
4872
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4873
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4874
+ #
4875
+ # References:
4876
+ #
4877
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/410).
4878
+ # * [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-410-gone).
4879
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#410).
3778
4880
  #
3779
4881
  class HTTPGone < HTTPClientError
3780
4882
  HAS_BODY: bool
@@ -3784,8 +4886,18 @@ module Net
3784
4886
  # Response class for `Length Required` responses (status code 411).
3785
4887
  #
3786
4888
  # The request did not specify the length of its content, which is required by
3787
- # the requested resource. See [411 Length
3788
- # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#411).
4889
+ # the requested resource.
4890
+ #
4891
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4892
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4893
+ #
4894
+ # References:
4895
+ #
4896
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/411).
4897
+ # * [RFC
4898
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-411-length-required
4899
+ # ).
4900
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#411).
3789
4901
  #
3790
4902
  class HTTPLengthRequired < HTTPClientError
3791
4903
  HAS_BODY: bool
@@ -3795,8 +4907,18 @@ module Net
3795
4907
  # Response class for `Precondition Failed` responses (status code 412).
3796
4908
  #
3797
4909
  # The server does not meet one of the preconditions specified in the request
3798
- # headers. See [412 Precondition
3799
- # Failed](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#412).
4910
+ # headers.
4911
+ #
4912
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4913
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4914
+ #
4915
+ # References:
4916
+ #
4917
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412).
4918
+ # * [RFC
4919
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-412-precondition-fa
4920
+ # iled).
4921
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#412).
3800
4922
  #
3801
4923
  class HTTPPreconditionFailed < HTTPClientError
3802
4924
  HAS_BODY: bool
@@ -3805,9 +4927,18 @@ module Net
3805
4927
  # <!-- rdoc-file=lib/net/http/responses.rb -->
3806
4928
  # Response class for `Payload Too Large` responses (status code 413).
3807
4929
  #
3808
- # The request is larger than the server is willing or able to process. See [413
3809
- # Payload Too
3810
- # Large](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413).
4930
+ # The request is larger than the server is willing or able to process.
4931
+ #
4932
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4933
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4934
+ #
4935
+ # References:
4936
+ #
4937
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413).
4938
+ # * [RFC
4939
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-413-content-too-lar
4940
+ # ge).
4941
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413).
3811
4942
  #
3812
4943
  class HTTPPayloadTooLarge < HTTPClientError
3813
4944
  HAS_BODY: bool
@@ -3816,8 +4947,17 @@ module Net
3816
4947
  # <!-- rdoc-file=lib/net/http/responses.rb -->
3817
4948
  # Response class for `URI Too Long` responses (status code 414).
3818
4949
  #
3819
- # The URI provided was too long for the server to process. See [414 URI Too
3820
- # Long](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414).
4950
+ # The URI provided was too long for the server to process.
4951
+ #
4952
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4953
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4954
+ #
4955
+ # References:
4956
+ #
4957
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414).
4958
+ # * [RFC
4959
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-414-uri-too-long).
4960
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414).
3821
4961
  #
3822
4962
  class HTTPURITooLong < HTTPClientError
3823
4963
  HAS_BODY: bool
@@ -3827,8 +4967,18 @@ module Net
3827
4967
  # Response class for `Unsupported Media Type` responses (status code 415).
3828
4968
  #
3829
4969
  # The request entity has a media type which the server or resource does not
3830
- # support. See [415 Unsupported Media
3831
- # Type](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415).
4970
+ # support.
4971
+ #
4972
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4973
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4974
+ #
4975
+ # References:
4976
+ #
4977
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415).
4978
+ # * [RFC
4979
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-415-unsupported-med
4980
+ # ia-type).
4981
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415).
3832
4982
  #
3833
4983
  class HTTPUnsupportedMediaType < HTTPClientError
3834
4984
  HAS_BODY: bool
@@ -3838,8 +4988,18 @@ module Net
3838
4988
  # Response class for `Range Not Satisfiable` responses (status code 416).
3839
4989
  #
3840
4990
  # The request entity has a media type which the server or resource does not
3841
- # support. See [416 Range Not
3842
- # Satisfiable](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416).
4991
+ # support.
4992
+ #
4993
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
4994
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
4995
+ #
4996
+ # References:
4997
+ #
4998
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416).
4999
+ # * [RFC
5000
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-416-range-not-satis
5001
+ # fiable).
5002
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416).
3843
5003
  #
3844
5004
  class HTTPRangeNotSatisfiable < HTTPClientError
3845
5005
  HAS_BODY: bool
@@ -3849,8 +5009,17 @@ module Net
3849
5009
  # Response class for `Expectation Failed` responses (status code 417).
3850
5010
  #
3851
5011
  # The server cannot meet the requirements of the Expect request-header field.
3852
- # See [417 Expectation
3853
- # Failed](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#417).
5012
+ #
5013
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5014
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5015
+ #
5016
+ # References:
5017
+ #
5018
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/417).
5019
+ # * [RFC
5020
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-417-expectation-fai
5021
+ # led).
5022
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#417).
3854
5023
  #
3855
5024
  class HTTPExpectationFailed < HTTPClientError
3856
5025
  HAS_BODY: bool
@@ -3860,8 +5029,16 @@ module Net
3860
5029
  # Response class for `Misdirected Request` responses (status code 421).
3861
5030
  #
3862
5031
  # The request was directed at a server that is not able to produce a response.
3863
- # See [421 Misdirected
3864
- # Request](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421).
5032
+ #
5033
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5034
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5035
+ #
5036
+ # References:
5037
+ #
5038
+ # * [RFC
5039
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-421-misdirected-req
5040
+ # uest).
5041
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421).
3865
5042
  #
3866
5043
  class HTTPMisdirectedRequest < HTTPClientError
3867
5044
  HAS_BODY: bool
@@ -3870,8 +5047,18 @@ module Net
3870
5047
  # <!-- rdoc-file=lib/net/http/responses.rb -->
3871
5048
  # Response class for `Unprocessable Entity` responses (status code 422).
3872
5049
  #
3873
- # The request was well-formed but had semantic errors. See [422 Unprocessable
3874
- # Entity](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#422).
5050
+ # The request was well-formed but had semantic errors.
5051
+ #
5052
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5053
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5054
+ #
5055
+ # References:
5056
+ #
5057
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422).
5058
+ # * [RFC
5059
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-422-unprocessable-c
5060
+ # ontent).
5061
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#422).
3875
5062
  #
3876
5063
  class HTTPUnprocessableEntity < HTTPClientError
3877
5064
  HAS_BODY: bool
@@ -3880,8 +5067,15 @@ module Net
3880
5067
  # <!-- rdoc-file=lib/net/http/responses.rb -->
3881
5068
  # Response class for `Locked (WebDAV)` responses (status code 423).
3882
5069
  #
3883
- # The requested resource is locked. See [423 Locked
3884
- # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#423).
5070
+ # The requested resource is locked.
5071
+ #
5072
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5073
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5074
+ #
5075
+ # References:
5076
+ #
5077
+ # * [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918#section-11.3).
5078
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#423).
3885
5079
  #
3886
5080
  class HTTPLocked < HTTPClientError
3887
5081
  HAS_BODY: bool
@@ -3894,6 +5088,14 @@ module Net
3894
5088
  # failed. See [424 Failed Dependency
3895
5089
  # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424).
3896
5090
  #
5091
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5092
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5093
+ #
5094
+ # References:
5095
+ #
5096
+ # * [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918#section-11.4).
5097
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424).
5098
+ #
3897
5099
  class HTTPFailedDependency < HTTPClientError
3898
5100
  HAS_BODY: bool
3899
5101
  end
@@ -3902,8 +5104,17 @@ module Net
3902
5104
  # Response class for `Upgrade Required` responses (status code 426).
3903
5105
  #
3904
5106
  # The client should switch to the protocol given in the Upgrade header field.
3905
- # See [426 Upgrade
3906
- # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#426).
5107
+ #
5108
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5109
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5110
+ #
5111
+ # References:
5112
+ #
5113
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/426).
5114
+ # * [RFC
5115
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-426-upgrade-require
5116
+ # d).
5117
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#426).
3907
5118
  #
3908
5119
  class HTTPUpgradeRequired < HTTPClientError
3909
5120
  HAS_BODY: bool
@@ -3912,9 +5123,16 @@ module Net
3912
5123
  # <!-- rdoc-file=lib/net/http/responses.rb -->
3913
5124
  # Response class for `Precondition Required` responses (status code 428).
3914
5125
  #
3915
- # The origin server requires the request to be conditional. See [428
3916
- # Precondition
3917
- # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#428).
5126
+ # The origin server requires the request to be conditional.
5127
+ #
5128
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5129
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5130
+ #
5131
+ # References:
5132
+ #
5133
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/428).
5134
+ # * [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-3).
5135
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#428).
3918
5136
  #
3919
5137
  class HTTPPreconditionRequired < HTTPClientError
3920
5138
  HAS_BODY: bool
@@ -3923,8 +5141,16 @@ module Net
3923
5141
  # <!-- rdoc-file=lib/net/http/responses.rb -->
3924
5142
  # Response class for `Too Many Requests` responses (status code 429).
3925
5143
  #
3926
- # The user has sent too many requests in a given amount of time. See [429 Too
3927
- # Many Requests](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429).
5144
+ # The user has sent too many requests in a given amount of time.
5145
+ #
5146
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5147
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5148
+ #
5149
+ # References:
5150
+ #
5151
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429).
5152
+ # * [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-4).
5153
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429).
3928
5154
  #
3929
5155
  class HTTPTooManyRequests < HTTPClientError
3930
5156
  HAS_BODY: bool
@@ -3935,8 +5161,16 @@ module Net
3935
5161
  # 431).
3936
5162
  #
3937
5163
  # An individual header field is too large, or all the header fields
3938
- # collectively, are too large. See [431 Request Header Fields Too
3939
- # Large](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#431).
5164
+ # collectively, are too large.
5165
+ #
5166
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5167
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5168
+ #
5169
+ # References:
5170
+ #
5171
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/431).
5172
+ # * [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-5).
5173
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#431).
3940
5174
  #
3941
5175
  class HTTPRequestHeaderFieldsTooLarge < HTTPClientError
3942
5176
  HAS_BODY: bool
@@ -3947,9 +5181,16 @@ module Net
3947
5181
  # 451).
3948
5182
  #
3949
5183
  # A server operator has received a legal demand to deny access to a resource or
3950
- # to a set of resources that includes the requested resource. See [451
3951
- # Unavailable For Legal
3952
- # Reasons](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#451).
5184
+ # to a set of resources that includes the requested resource.
5185
+ #
5186
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5187
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5188
+ #
5189
+ # References:
5190
+ #
5191
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451).
5192
+ # * [RFC 7725](https://www.rfc-editor.org/rfc/rfc7725.html#section-3).
5193
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#451).
3953
5194
  #
3954
5195
  class HTTPUnavailableForLegalReasons < HTTPClientError
3955
5196
  HAS_BODY: bool
@@ -3959,8 +5200,18 @@ module Net
3959
5200
  # Response class for `Internal Server Error` responses (status code 500).
3960
5201
  #
3961
5202
  # An unexpected condition was encountered and no more specific message is
3962
- # suitable. See [500 Internal Server
3963
- # Error](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#500).
5203
+ # suitable.
5204
+ #
5205
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5206
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5207
+ #
5208
+ # References:
5209
+ #
5210
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500).
5211
+ # * [RFC
5212
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-500-internal-server
5213
+ # -error).
5214
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#500).
3964
5215
  #
3965
5216
  class HTTPInternalServerError < HTTPServerError
3966
5217
  HAS_BODY: bool
@@ -3970,8 +5221,18 @@ module Net
3970
5221
  # Response class for `Not Implemented` responses (status code 501).
3971
5222
  #
3972
5223
  # The server either does not recognize the request method, or it lacks the
3973
- # ability to fulfil the request. See [501 Not
3974
- # Implemented](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#501).
5224
+ # ability to fulfil the request.
5225
+ #
5226
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5227
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5228
+ #
5229
+ # References:
5230
+ #
5231
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501).
5232
+ # * [RFC
5233
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-501-not-implemented
5234
+ # ).
5235
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#501).
3975
5236
  #
3976
5237
  class HTTPNotImplemented < HTTPServerError
3977
5238
  HAS_BODY: bool
@@ -3981,8 +5242,17 @@ module Net
3981
5242
  # Response class for `Bad Gateway` responses (status code 502).
3982
5243
  #
3983
5244
  # The server was acting as a gateway or proxy and received an invalid response
3984
- # from the upstream server. See [502 Bad
3985
- # Gateway](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#502).
5245
+ # from the upstream server.
5246
+ #
5247
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5248
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5249
+ #
5250
+ # References:
5251
+ #
5252
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502).
5253
+ # * [RFC
5254
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-502-bad-gateway).
5255
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#502).
3986
5256
  #
3987
5257
  class HTTPBadGateway < HTTPServerError
3988
5258
  HAS_BODY: bool
@@ -3992,8 +5262,18 @@ module Net
3992
5262
  # Response class for `Service Unavailable` responses (status code 503).
3993
5263
  #
3994
5264
  # The server cannot handle the request (because it is overloaded or down for
3995
- # maintenance). See [503 Service
3996
- # Unavailable](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#503).
5265
+ # maintenance).
5266
+ #
5267
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5268
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5269
+ #
5270
+ # References:
5271
+ #
5272
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503).
5273
+ # * [RFC
5274
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-503-service-unavail
5275
+ # able).
5276
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#503).
3997
5277
  #
3998
5278
  class HTTPServiceUnavailable < HTTPServerError
3999
5279
  HAS_BODY: bool
@@ -4003,8 +5283,18 @@ module Net
4003
5283
  # Response class for `Gateway Timeout` responses (status code 504).
4004
5284
  #
4005
5285
  # The server was acting as a gateway or proxy and did not receive a timely
4006
- # response from the upstream server. See [504 Gateway
4007
- # Timeout](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#504).
5286
+ # response from the upstream server.
5287
+ #
5288
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5289
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5290
+ #
5291
+ # References:
5292
+ #
5293
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504).
5294
+ # * [RFC
5295
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-504-gateway-timeout
5296
+ # ).
5297
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#504).
4008
5298
  #
4009
5299
  class HTTPGatewayTimeout < HTTPServerError
4010
5300
  HAS_BODY: bool
@@ -4013,9 +5303,18 @@ module Net
4013
5303
  # <!-- rdoc-file=lib/net/http/responses.rb -->
4014
5304
  # Response class for `HTTP Version Not Supported` responses (status code 505).
4015
5305
  #
4016
- # The server does not support the HTTP version used in the request. See [505
4017
- # HTTP Version Not
4018
- # Supported](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#505).
5306
+ # The server does not support the HTTP version used in the request.
5307
+ #
5308
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5309
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5310
+ #
5311
+ # References:
5312
+ #
5313
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/505).
5314
+ # * [RFC
5315
+ # 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-505-http-version-no
5316
+ # t-suppor).
5317
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#505).
4019
5318
  #
4020
5319
  class HTTPVersionNotSupported < HTTPServerError
4021
5320
  HAS_BODY: bool
@@ -4025,8 +5324,16 @@ module Net
4025
5324
  # Response class for `Variant Also Negotiates` responses (status code 506).
4026
5325
  #
4027
5326
  # Transparent content negotiation for the request results in a circular
4028
- # reference. See [506 Variant Also
4029
- # Negotiates](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506).
5327
+ # reference.
5328
+ #
5329
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5330
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5331
+ #
5332
+ # References:
5333
+ #
5334
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/506).
5335
+ # * [RFC 2295](https://www.rfc-editor.org/rfc/rfc2295#section-8.1).
5336
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506).
4030
5337
  #
4031
5338
  class HTTPVariantAlsoNegotiates < HTTPServerError
4032
5339
  HAS_BODY: bool
@@ -4037,8 +5344,16 @@ module Net
4037
5344
  # 507).
4038
5345
  #
4039
5346
  # The server is unable to store the representation needed to complete the
4040
- # request. See [507 Insufficient Storage
4041
- # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#507).
5347
+ # request.
5348
+ #
5349
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5350
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5351
+ #
5352
+ # References:
5353
+ #
5354
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507).
5355
+ # * [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918#section-11.5).
5356
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#507).
4042
5357
  #
4043
5358
  class HTTPInsufficientStorage < HTTPServerError
4044
5359
  HAS_BODY: bool
@@ -4047,9 +5362,16 @@ module Net
4047
5362
  # <!-- rdoc-file=lib/net/http/responses.rb -->
4048
5363
  # Response class for `Loop Detected (WebDAV)` responses (status code 508).
4049
5364
  #
4050
- # The server detected an infinite loop while processing the request. See [508
4051
- # Loop Detected
4052
- # (WebDAV)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508).
5365
+ # The server detected an infinite loop while processing the request.
5366
+ #
5367
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5368
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5369
+ #
5370
+ # References:
5371
+ #
5372
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/508).
5373
+ # * [RFC 5942](https://www.rfc-editor.org/rfc/rfc5842.html#section-7.2).
5374
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508).
4053
5375
  #
4054
5376
  class HTTPLoopDetected < HTTPServerError
4055
5377
  HAS_BODY: bool
@@ -4059,8 +5381,15 @@ module Net
4059
5381
  # Response class for `Not Extended` responses (status code 510).
4060
5382
  #
4061
5383
  # Further extensions to the request are required for the server to fulfill it.
4062
- # See [510 Not
4063
- # Extended](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510).
5384
+ #
5385
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5386
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5387
+ #
5388
+ # References:
5389
+ #
5390
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/510).
5391
+ # * [RFC 2774](https://www.rfc-editor.org/rfc/rfc2774.html#section-7).
5392
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510).
4064
5393
  #
4065
5394
  class HTTPNotExtended < HTTPServerError
4066
5395
  HAS_BODY: bool
@@ -4070,16 +5399,23 @@ module Net
4070
5399
  # Response class for `Network Authentication Required` responses (status code
4071
5400
  # 511).
4072
5401
  #
4073
- # The client needs to authenticate to gain network access. See [511 Network
4074
- # Authentication
4075
- # Required](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#511).
5402
+ # The client needs to authenticate to gain network access.
5403
+ #
5404
+ # This class also includes (indirectly) module Net::HTTPHeader, which gives
5405
+ # access to its [methods for getting headers](rdoc-ref:Net::HTTPHeader@Getters).
5406
+ #
5407
+ # References:
5408
+ #
5409
+ # * [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511).
5410
+ # * [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585#section-6).
5411
+ # * [Wikipedia](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#511).
4076
5412
  #
4077
5413
  class HTTPNetworkAuthenticationRequired < HTTPServerError
4078
5414
  HAS_BODY: bool
4079
5415
  end
4080
5416
 
4081
5417
  # <!-- rdoc-file=lib/net/http/response.rb -->
4082
- # This class is the base class for Net::HTTP request classes.
5418
+ # This class is the base class for Net::HTTP response classes.
4083
5419
  #
4084
5420
  # ## About the Examples
4085
5421
  #
@@ -4096,9 +5432,10 @@ module Net
4096
5432
  #
4097
5433
  # Some examples also assume these variables:
4098
5434
  #
4099
- # uri = URI('https://jsonplaceholder.typicode.com')
5435
+ # uri = URI('https://jsonplaceholder.typicode.com/')
4100
5436
  # uri.freeze # Examples may not modify.
4101
5437
  # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
5438
+ # path = uri.path # => "/"
4102
5439
  # port = uri.port # => 443
4103
5440
  #
4104
5441
  # So that example requests may be written as: