rbs 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +5 -0
  3. data/CHANGELOG.md +23 -0
  4. data/README.md +6 -1
  5. data/core/array.rbs +2866 -1086
  6. data/core/basic_object.rbs +150 -30
  7. data/core/binding.rbs +33 -0
  8. data/core/builtin.rbs +4 -4
  9. data/core/class.rbs +43 -5
  10. data/core/comparable.rbs +57 -0
  11. data/core/complex.rbs +170 -4
  12. data/core/constants.rbs +51 -0
  13. data/core/deprecated.rbs +7 -0
  14. data/core/dir.rbs +305 -20
  15. data/core/encoding.rbs +472 -77
  16. data/core/enumerable.rbs +2173 -234
  17. data/core/enumerator.rbs +448 -182
  18. data/core/env.rbs +448 -1
  19. data/core/errno.rbs +1 -10
  20. data/core/errors.rbs +152 -2
  21. data/core/exception.rbs +201 -127
  22. data/core/false_class.rbs +27 -0
  23. data/core/fiber.rbs +118 -37
  24. data/core/fiber_error.rbs +8 -9
  25. data/core/file.rbs +1059 -139
  26. data/core/file_test.rbs +287 -32
  27. data/core/float.rbs +776 -300
  28. data/core/gc.rbs +185 -34
  29. data/core/global_variables.rbs +5 -1
  30. data/core/hash.rbs +1582 -649
  31. data/core/integer.rbs +974 -204
  32. data/core/io/buffer.rbs +710 -0
  33. data/core/io/wait.rbs +29 -8
  34. data/core/io.rbs +2438 -417
  35. data/core/kernel.rbs +2315 -316
  36. data/core/marshal.rbs +37 -2
  37. data/core/match_data.rbs +123 -6
  38. data/core/math.rbs +126 -6
  39. data/core/method.rbs +226 -102
  40. data/core/module.rbs +421 -45
  41. data/core/nil_class.rbs +64 -0
  42. data/core/numeric.rbs +620 -142
  43. data/core/object.rbs +453 -81
  44. data/core/object_space.rbs +92 -2
  45. data/core/proc.rbs +482 -285
  46. data/core/process.rbs +443 -34
  47. data/core/ractor.rbs +232 -9
  48. data/core/random.rbs +151 -52
  49. data/core/range.rbs +885 -160
  50. data/core/rational.rbs +122 -6
  51. data/core/rb_config.rbs +14 -4
  52. data/core/refinement.rbs +44 -0
  53. data/core/regexp.rbs +156 -14
  54. data/core/ruby_vm.rbs +42 -3
  55. data/core/signal.rbs +78 -39
  56. data/core/string.rbs +2123 -567
  57. data/core/string_io.rbs +204 -0
  58. data/core/struct.rbs +283 -28
  59. data/core/symbol.rbs +304 -30
  60. data/core/thread.rbs +1288 -688
  61. data/core/thread_group.rbs +66 -10
  62. data/core/time.rbs +643 -217
  63. data/core/trace_point.rbs +100 -12
  64. data/core/true_class.rbs +24 -0
  65. data/core/unbound_method.rbs +73 -7
  66. data/core/warning.rbs +37 -12
  67. data/docs/CONTRIBUTING.md +40 -34
  68. data/docs/stdlib.md +3 -102
  69. data/lib/rbs/annotate/annotations.rb +197 -0
  70. data/lib/rbs/annotate/formatter.rb +80 -0
  71. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  72. data/lib/rbs/annotate/rdoc_source.rb +120 -0
  73. data/lib/rbs/annotate.rb +6 -0
  74. data/lib/rbs/cli.rb +45 -1
  75. data/lib/rbs/definition_builder.rb +5 -1
  76. data/lib/rbs/location_aux.rb +12 -0
  77. data/lib/rbs/prototype/rb.rb +12 -0
  78. data/lib/rbs/version.rb +1 -1
  79. data/sig/annotate/annotations.rbs +102 -0
  80. data/sig/annotate/formatter.rbs +24 -0
  81. data/sig/annotate/rdoc_annotater.rbs +82 -0
  82. data/sig/annotate/rdoc_source.rbs +30 -0
  83. data/sig/cli.rbs +2 -0
  84. data/sig/collection/{collections.rbs → sources.rbs} +0 -0
  85. data/sig/location.rbs +6 -0
  86. data/sig/method_types.rbs +5 -1
  87. data/sig/polyfill.rbs +78 -0
  88. data/stdlib/abbrev/0/abbrev.rbs +6 -0
  89. data/stdlib/abbrev/0/array.rbs +26 -0
  90. data/stdlib/base64/0/base64.rbs +31 -0
  91. data/stdlib/benchmark/0/benchmark.rbs +74 -3
  92. data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
  93. data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
  94. data/stdlib/cgi/0/core.rbs +59 -0
  95. data/stdlib/coverage/0/coverage.rbs +164 -2
  96. data/stdlib/csv/0/csv.rbs +2862 -398
  97. data/stdlib/date/0/date.rbs +483 -25
  98. data/stdlib/date/0/date_time.rbs +187 -12
  99. data/stdlib/dbm/0/dbm.rbs +152 -17
  100. data/stdlib/digest/0/digest.rbs +146 -0
  101. data/stdlib/erb/0/erb.rbs +65 -245
  102. data/stdlib/fiber/0/fiber.rbs +73 -91
  103. data/stdlib/fileutils/0/fileutils.rbs +301 -1
  104. data/stdlib/find/0/find.rbs +9 -0
  105. data/stdlib/forwardable/0/forwardable.rbs +65 -1
  106. data/stdlib/io-console/0/io-console.rbs +227 -15
  107. data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
  108. data/stdlib/json/0/json.rbs +1146 -144
  109. data/stdlib/logger/0/formatter.rbs +24 -0
  110. data/stdlib/logger/0/log_device.rbs +64 -0
  111. data/stdlib/logger/0/logger.rbs +165 -13
  112. data/stdlib/logger/0/period.rbs +10 -0
  113. data/stdlib/logger/0/severity.rbs +26 -0
  114. data/stdlib/monitor/0/monitor.rbs +163 -0
  115. data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
  116. data/stdlib/net-http/0/net-http.rbs +1492 -683
  117. data/stdlib/nkf/0/nkf.rbs +372 -0
  118. data/stdlib/objspace/0/objspace.rbs +149 -90
  119. data/stdlib/openssl/0/openssl.rbs +8108 -71
  120. data/stdlib/optparse/0/optparse.rbs +487 -19
  121. data/stdlib/pathname/0/pathname.rbs +425 -124
  122. data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
  123. data/stdlib/prime/0/integer-extension.rbs +20 -2
  124. data/stdlib/prime/0/prime.rbs +88 -21
  125. data/stdlib/pstore/0/pstore.rbs +102 -0
  126. data/stdlib/pty/0/pty.rbs +64 -14
  127. data/stdlib/resolv/0/resolv.rbs +420 -31
  128. data/stdlib/rubygems/0/basic_specification.rbs +4 -1
  129. data/stdlib/rubygems/0/config_file.rbs +33 -1
  130. data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
  131. data/stdlib/rubygems/0/installer.rbs +13 -1
  132. data/stdlib/rubygems/0/path_support.rbs +4 -1
  133. data/stdlib/rubygems/0/platform.rbs +5 -1
  134. data/stdlib/rubygems/0/request_set.rbs +44 -2
  135. data/stdlib/rubygems/0/requirement.rbs +65 -2
  136. data/stdlib/rubygems/0/rubygems.rbs +407 -0
  137. data/stdlib/rubygems/0/source_list.rbs +13 -0
  138. data/stdlib/rubygems/0/specification.rbs +21 -1
  139. data/stdlib/rubygems/0/stream_ui.rbs +3 -1
  140. data/stdlib/rubygems/0/uninstaller.rbs +8 -1
  141. data/stdlib/rubygems/0/version.rbs +60 -157
  142. data/stdlib/securerandom/0/securerandom.rbs +44 -0
  143. data/stdlib/set/0/set.rbs +420 -106
  144. data/stdlib/shellwords/0/shellwords.rbs +55 -77
  145. data/stdlib/singleton/0/singleton.rbs +20 -0
  146. data/stdlib/socket/0/addrinfo.rbs +210 -9
  147. data/stdlib/socket/0/basic_socket.rbs +103 -11
  148. data/stdlib/socket/0/ip_socket.rbs +31 -9
  149. data/stdlib/socket/0/socket.rbs +586 -38
  150. data/stdlib/socket/0/tcp_server.rbs +22 -2
  151. data/stdlib/socket/0/tcp_socket.rbs +12 -1
  152. data/stdlib/socket/0/udp_socket.rbs +25 -2
  153. data/stdlib/socket/0/unix_server.rbs +22 -2
  154. data/stdlib/socket/0/unix_socket.rbs +45 -5
  155. data/stdlib/strscan/0/string_scanner.rbs +210 -9
  156. data/stdlib/tempfile/0/tempfile.rbs +58 -10
  157. data/stdlib/time/0/time.rbs +208 -116
  158. data/stdlib/timeout/0/timeout.rbs +10 -0
  159. data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
  160. data/stdlib/tsort/0/cyclic.rbs +1 -0
  161. data/stdlib/tsort/0/interfaces.rbs +1 -0
  162. data/stdlib/tsort/0/tsort.rbs +42 -0
  163. data/stdlib/uri/0/common.rbs +57 -8
  164. data/stdlib/uri/0/file.rbs +55 -109
  165. data/stdlib/uri/0/ftp.rbs +6 -3
  166. data/stdlib/uri/0/generic.rbs +556 -327
  167. data/stdlib/uri/0/http.rbs +26 -115
  168. data/stdlib/uri/0/https.rbs +8 -102
  169. data/stdlib/uri/0/ldap.rbs +143 -137
  170. data/stdlib/uri/0/ldaps.rbs +8 -102
  171. data/stdlib/uri/0/mailto.rbs +3 -0
  172. data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
  173. data/stdlib/uri/0/ws.rbs +6 -3
  174. data/stdlib/uri/0/wss.rbs +5 -3
  175. data/stdlib/yaml/0/dbm.rbs +151 -87
  176. data/stdlib/yaml/0/store.rbs +6 -0
  177. data/stdlib/zlib/0/zlib.rbs +90 -31
  178. metadata +17 -5
  179. data/lib/rbs/location.rb +0 -221
@@ -5,288 +5,290 @@ module Net
5
5
 
6
6
  class ProtocolError < StandardError
7
7
  end
8
+
8
9
  class ProtoSyntaxError < ProtocolError
9
10
  end
11
+
10
12
  class ProtoFatalError < ProtocolError
11
13
  end
14
+
12
15
  class ProtoUnknownError < ProtocolError
13
16
  end
17
+
14
18
  class ProtoServerError < ProtocolError
15
19
  end
20
+
16
21
  class ProtoAuthError < ProtocolError
17
22
  end
23
+
18
24
  class ProtoCommandError < ProtocolError
19
25
  end
26
+
20
27
  class ProtoRetriableError < ProtocolError
21
28
  end
22
- # ProtocRetryError = ProtoRetriableError
23
29
 
24
- # :stopdoc:
25
30
  class HTTPBadResponse < StandardError
26
31
  end
27
32
 
28
33
  class HTTPHeaderSyntaxError < StandardError
29
34
  end
30
35
 
31
- # == An HTTP client API for Ruby.
36
+ # <!-- rdoc-file=lib/net/http.rb -->
37
+ # ## An HTTP client API for Ruby.
32
38
  #
33
- # Net::HTTP provides a rich library which can be used to build HTTP
34
- # user-agents. For more details about HTTP see
39
+ # Net::HTTP provides a rich library which can be used to build HTTP user-agents.
40
+ # For more details about HTTP see
35
41
  # [RFC2616](http://www.ietf.org/rfc/rfc2616.txt).
36
42
  #
37
43
  # Net::HTTP is designed to work closely with URI. URI::HTTP#host,
38
- # URI::HTTP#port and URI::HTTP#request_uri are designed to work with
39
- # Net::HTTP.
44
+ # URI::HTTP#port and URI::HTTP#request_uri are designed to work with Net::HTTP.
40
45
  #
41
46
  # If you are only performing a few GET requests you should try OpenURI.
42
47
  #
43
- # == Simple Examples
48
+ # ## Simple Examples
44
49
  #
45
50
  # All examples assume you have loaded Net::HTTP with:
46
51
  #
47
- # require 'net/http'
52
+ # require 'net/http'
48
53
  #
49
54
  # This will also require 'uri' so you don't need to require it separately.
50
55
  #
51
- # The Net::HTTP methods in the following section do not persist
52
- # connections. They are not recommended if you are performing many HTTP
53
- # requests.
56
+ # The Net::HTTP methods in the following section do not persist connections.
57
+ # They are not recommended if you are performing many HTTP requests.
54
58
  #
55
- # === GET
59
+ # ### GET
56
60
  #
57
- # Net::HTTP.get('example.com', '/index.html') # => String
61
+ # Net::HTTP.get('example.com', '/index.html') # => String
58
62
  #
59
- # === GET by URI
63
+ # ### GET by URI
60
64
  #
61
- # uri = URI('http://example.com/index.html?count=10')
62
- # Net::HTTP.get(uri) # => String
65
+ # uri = URI('http://example.com/index.html?count=10')
66
+ # Net::HTTP.get(uri) # => String
63
67
  #
64
- # === GET with Dynamic Parameters
68
+ # ### GET with Dynamic Parameters
65
69
  #
66
- # uri = URI('http://example.com/index.html')
67
- # params = { :limit => 10, :page => 3 }
68
- # uri.query = URI.encode_www_form(params)
70
+ # uri = URI('http://example.com/index.html')
71
+ # params = { :limit => 10, :page => 3 }
72
+ # uri.query = URI.encode_www_form(params)
69
73
  #
70
- # res = Net::HTTP.get_response(uri)
71
- # puts res.body if res.is_a?(Net::HTTPSuccess)
74
+ # res = Net::HTTP.get_response(uri)
75
+ # puts res.body if res.is_a?(Net::HTTPSuccess)
72
76
  #
73
- # === POST
77
+ # ### POST
74
78
  #
75
- # uri = URI('http://www.example.com/search.cgi')
76
- # res = Net::HTTP.post_form(uri, 'q' => 'ruby', 'max' => '50')
77
- # puts res.body
79
+ # uri = URI('http://www.example.com/search.cgi')
80
+ # res = Net::HTTP.post_form(uri, 'q' => 'ruby', 'max' => '50')
81
+ # puts res.body
78
82
  #
79
- # === POST with Multiple Values
83
+ # ### POST with Multiple Values
80
84
  #
81
- # uri = URI('http://www.example.com/search.cgi')
82
- # res = Net::HTTP.post_form(uri, 'q' => ['ruby', 'perl'], 'max' => '50')
83
- # puts res.body
85
+ # uri = URI('http://www.example.com/search.cgi')
86
+ # res = Net::HTTP.post_form(uri, 'q' => ['ruby', 'perl'], 'max' => '50')
87
+ # puts res.body
84
88
  #
85
- # == How to use Net::HTTP
89
+ # ## How to use Net::HTTP
86
90
  #
87
91
  # The following example code can be used as the basis of an HTTP user-agent
88
- # which can perform a variety of request types using persistent
89
- # connections.
92
+ # which can perform a variety of request types using persistent connections.
90
93
  #
91
- # uri = URI('http://example.com/some_path?query=string')
94
+ # uri = URI('http://example.com/some_path?query=string')
92
95
  #
93
- # Net::HTTP.start(uri.host, uri.port) do |http|
94
- # request = Net::HTTP::Get.new uri
96
+ # Net::HTTP.start(uri.host, uri.port) do |http|
97
+ # request = Net::HTTP::Get.new uri
95
98
  #
96
- # response = http.request request # Net::HTTPResponse object
97
- # end
99
+ # response = http.request request # Net::HTTPResponse object
100
+ # end
98
101
  #
99
- # Net::HTTP::start immediately creates a connection to an HTTP server which
100
- # is kept open for the duration of the block. The connection will remain
101
- # open for multiple requests in the block if the server indicates it
102
- # supports persistent connections.
102
+ # Net::HTTP::start immediately creates a connection to an HTTP server which is
103
+ # kept open for the duration of the block. The connection will remain open for
104
+ # multiple requests in the block if the server indicates it supports persistent
105
+ # connections.
103
106
  #
104
107
  # If you wish to re-use a connection across multiple HTTP requests without
105
- # automatically closing it you can use ::new and then call #start and
106
- # #finish manually.
108
+ # automatically closing it you can use ::new and then call #start and #finish
109
+ # manually.
107
110
  #
108
111
  # The request types Net::HTTP supports are listed below in the section "HTTP
109
112
  # Request Classes".
110
113
  #
111
114
  # For all the Net::HTTP request objects and shortcut request methods you may
112
- # supply either a String for the request path or a URI from which Net::HTTP
113
- # will extract the request path.
115
+ # supply either a String for the request path or a URI from which Net::HTTP will
116
+ # extract the request path.
114
117
  #
115
- # === Response Data
118
+ # ### Response Data
116
119
  #
117
- # uri = URI('http://example.com/index.html')
118
- # res = Net::HTTP.get_response(uri)
120
+ # uri = URI('http://example.com/index.html')
121
+ # res = Net::HTTP.get_response(uri)
119
122
  #
120
- # # Headers
121
- # res['Set-Cookie'] # => String
122
- # res.get_fields('set-cookie') # => Array
123
- # res.to_hash['set-cookie'] # => Array
124
- # puts "Headers: #{res.to_hash.inspect}"
123
+ # # Headers
124
+ # res['Set-Cookie'] # => String
125
+ # res.get_fields('set-cookie') # => Array
126
+ # res.to_hash['set-cookie'] # => Array
127
+ # puts "Headers: #{res.to_hash.inspect}"
125
128
  #
126
- # # Status
127
- # puts res.code # => '200'
128
- # puts res.message # => 'OK'
129
- # puts res.class.name # => 'HTTPOK'
129
+ # # Status
130
+ # puts res.code # => '200'
131
+ # puts res.message # => 'OK'
132
+ # puts res.class.name # => 'HTTPOK'
130
133
  #
131
- # # Body
132
- # puts res.body if res.response_body_permitted?
134
+ # # Body
135
+ # puts res.body if res.response_body_permitted?
133
136
  #
134
- # === Following Redirection
137
+ # ### Following Redirection
135
138
  #
136
139
  # Each Net::HTTPResponse object belongs to a class for its response code.
137
140
  #
138
- # For example, all 2XX responses are instances of a Net::HTTPSuccess
139
- # subclass, a 3XX response is an instance of a Net::HTTPRedirection
140
- # subclass and a 200 response is an instance of the Net::HTTPOK class. For
141
- # details of response classes, see the section "HTTP Response Classes"
142
- # below.
141
+ # For example, all 2XX responses are instances of a Net::HTTPSuccess subclass, a
142
+ # 3XX response is an instance of a Net::HTTPRedirection subclass and a 200
143
+ # response is an instance of the Net::HTTPOK class. For details of response
144
+ # classes, see the section "HTTP Response Classes" below.
143
145
  #
144
146
  # Using a case statement you can handle various types of responses properly:
145
147
  #
146
- # def fetch(uri_str, limit = 10)
147
- # # You should choose a better exception.
148
- # raise ArgumentError, 'too many HTTP redirects' if limit == 0
149
- #
150
- # response = Net::HTTP.get_response(URI(uri_str))
151
- #
152
- # case response
153
- # when Net::HTTPSuccess then
154
- # response
155
- # when Net::HTTPRedirection then
156
- # location = response['location']
157
- # warn "redirected to #{location}"
158
- # fetch(location, limit - 1)
159
- # else
160
- # response.value
148
+ # def fetch(uri_str, limit = 10)
149
+ # # You should choose a better exception.
150
+ # raise ArgumentError, 'too many HTTP redirects' if limit == 0
151
+ #
152
+ # response = Net::HTTP.get_response(URI(uri_str))
153
+ #
154
+ # case response
155
+ # when Net::HTTPSuccess then
156
+ # response
157
+ # when Net::HTTPRedirection then
158
+ # location = response['location']
159
+ # warn "redirected to #{location}"
160
+ # fetch(location, limit - 1)
161
+ # else
162
+ # response.value
163
+ # end
161
164
  # end
162
- # end
163
165
  #
164
- # print fetch('http://www.ruby-lang.org')
166
+ # print fetch('http://www.ruby-lang.org')
165
167
  #
166
- # === POST
168
+ # ### POST
167
169
  #
168
170
  # A POST can be made using the Net::HTTP::Post request class. This example
169
171
  # creates a URL encoded POST body:
170
172
  #
171
- # uri = URI('http://www.example.com/todo.cgi')
172
- # req = Net::HTTP::Post.new(uri)
173
- # req.set_form_data('from' => '2005-01-01', 'to' => '2005-03-31')
173
+ # uri = URI('http://www.example.com/todo.cgi')
174
+ # req = Net::HTTP::Post.new(uri)
175
+ # req.set_form_data('from' => '2005-01-01', 'to' => '2005-03-31')
174
176
  #
175
- # res = Net::HTTP.start(uri.hostname, uri.port) do |http|
176
- # http.request(req)
177
- # end
177
+ # res = Net::HTTP.start(uri.hostname, uri.port) do |http|
178
+ # http.request(req)
179
+ # end
178
180
  #
179
- # case res
180
- # when Net::HTTPSuccess, Net::HTTPRedirection
181
- # # OK
182
- # else
183
- # res.value
184
- # end
181
+ # case res
182
+ # when Net::HTTPSuccess, Net::HTTPRedirection
183
+ # # OK
184
+ # else
185
+ # res.value
186
+ # end
185
187
  #
186
188
  # To send multipart/form-data use Net::HTTPHeader#set_form:
187
189
  #
188
- # req = Net::HTTP::Post.new(uri)
189
- # req.set_form([['upload', File.open('foo.bar')]], 'multipart/form-data')
190
+ # req = Net::HTTP::Post.new(uri)
191
+ # req.set_form([['upload', File.open('foo.bar')]], 'multipart/form-data')
190
192
  #
191
- # Other requests that can contain a body such as PUT can be created in the
192
- # same way using the corresponding request class (Net::HTTP::Put).
193
+ # Other requests that can contain a body such as PUT can be created in the same
194
+ # way using the corresponding request class (Net::HTTP::Put).
193
195
  #
194
- # === Setting Headers
196
+ # ### Setting Headers
195
197
  #
196
- # The following example performs a conditional GET using the
197
- # If-Modified-Since header. If the files has not been modified since the
198
- # time in the header a Not Modified response will be returned. See RFC 2616
199
- # section 9.3 for further details.
198
+ # The following example performs a conditional GET using the If-Modified-Since
199
+ # header. If the files has not been modified since the time in the header a Not
200
+ # Modified response will be returned. See RFC 2616 section 9.3 for further
201
+ # details.
200
202
  #
201
- # uri = URI('http://example.com/cached_response')
202
- # file = File.stat 'cached_response'
203
+ # uri = URI('http://example.com/cached_response')
204
+ # file = File.stat 'cached_response'
203
205
  #
204
- # req = Net::HTTP::Get.new(uri)
205
- # req['If-Modified-Since'] = file.mtime.rfc2822
206
+ # req = Net::HTTP::Get.new(uri)
207
+ # req['If-Modified-Since'] = file.mtime.rfc2822
206
208
  #
207
- # res = Net::HTTP.start(uri.hostname, uri.port) {|http|
208
- # http.request(req)
209
- # }
209
+ # res = Net::HTTP.start(uri.hostname, uri.port) {|http|
210
+ # http.request(req)
211
+ # }
210
212
  #
211
- # open 'cached_response', 'w' do |io|
212
- # io.write res.body
213
- # end if res.is_a?(Net::HTTPSuccess)
213
+ # open 'cached_response', 'w' do |io|
214
+ # io.write res.body
215
+ # end if res.is_a?(Net::HTTPSuccess)
214
216
  #
215
- # === Basic Authentication
217
+ # ### Basic Authentication
216
218
  #
217
219
  # Basic authentication is performed according to
218
220
  # [RFC2617](http://www.ietf.org/rfc/rfc2617.txt).
219
221
  #
220
- # uri = URI('http://example.com/index.html?key=value')
222
+ # uri = URI('http://example.com/index.html?key=value')
221
223
  #
222
- # req = Net::HTTP::Get.new(uri)
223
- # req.basic_auth 'user', 'pass'
224
+ # req = Net::HTTP::Get.new(uri)
225
+ # req.basic_auth 'user', 'pass'
224
226
  #
225
- # res = Net::HTTP.start(uri.hostname, uri.port) {|http|
226
- # http.request(req)
227
- # }
228
- # puts res.body
227
+ # res = Net::HTTP.start(uri.hostname, uri.port) {|http|
228
+ # http.request(req)
229
+ # }
230
+ # puts res.body
229
231
  #
230
- # === Streaming Response Bodies
232
+ # ### Streaming Response Bodies
231
233
  #
232
234
  # By default Net::HTTP reads an entire response into memory. If you are
233
235
  # handling large files or wish to implement a progress bar you can instead
234
236
  # stream the body directly to an IO.
235
237
  #
236
- # uri = URI('http://example.com/large_file')
238
+ # uri = URI('http://example.com/large_file')
237
239
  #
238
- # Net::HTTP.start(uri.host, uri.port) do |http|
239
- # request = Net::HTTP::Get.new uri
240
+ # Net::HTTP.start(uri.host, uri.port) do |http|
241
+ # request = Net::HTTP::Get.new uri
240
242
  #
241
- # http.request request do |response|
242
- # open 'large_file', 'w' do |io|
243
- # response.read_body do |chunk|
244
- # io.write chunk
243
+ # http.request request do |response|
244
+ # open 'large_file', 'w' do |io|
245
+ # response.read_body do |chunk|
246
+ # io.write chunk
247
+ # end
245
248
  # end
246
249
  # end
247
250
  # end
248
- # end
249
251
  #
250
- # === HTTPS
252
+ # ### HTTPS
251
253
  #
252
254
  # HTTPS is enabled for an HTTP connection by Net::HTTP#use_ssl=.
253
255
  #
254
- # uri = URI('https://secure.example.com/some_path?query=string')
256
+ # uri = URI('https://secure.example.com/some_path?query=string')
255
257
  #
256
- # Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
257
- # request = Net::HTTP::Get.new uri
258
- # response = http.request request # Net::HTTPResponse object
259
- # end
258
+ # Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
259
+ # request = Net::HTTP::Get.new uri
260
+ # response = http.request request # Net::HTTPResponse object
261
+ # end
260
262
  #
261
- # Or if you simply want to make a GET request, you may pass in an URI
262
- # object that has an HTTPS URL. Net::HTTP automatically turns on TLS
263
- # verification if the URI object has a 'https' URI scheme.
263
+ # Or if you simply want to make a GET request, you may pass in an URI object
264
+ # that has an HTTPS URL. Net::HTTP automatically turns on TLS verification if
265
+ # the URI object has a 'https' URI scheme.
264
266
  #
265
- # uri = URI('https://example.com/')
266
- # Net::HTTP.get(uri) # => String
267
+ # uri = URI('https://example.com/')
268
+ # Net::HTTP.get(uri) # => String
267
269
  #
268
270
  # In previous versions of Ruby you would need to require 'net/https' to use
269
271
  # HTTPS. This is no longer true.
270
272
  #
271
- # === Proxies
273
+ # ### Proxies
272
274
  #
273
- # Net::HTTP will automatically create a proxy from the +http_proxy+
274
- # environment variable if it is present. To disable use of +http_proxy+,
275
- # pass +nil+ for the proxy address.
275
+ # Net::HTTP will automatically create a proxy from the `http_proxy` environment
276
+ # variable if it is present. To disable use of `http_proxy`, pass `nil` for the
277
+ # proxy address.
276
278
  #
277
279
  # You may also create a custom proxy:
278
280
  #
279
- # proxy_addr = 'your.proxy.host'
280
- # proxy_port = 8080
281
+ # proxy_addr = 'your.proxy.host'
282
+ # proxy_port = 8080
281
283
  #
282
- # Net::HTTP.new('example.com', nil, proxy_addr, proxy_port).start { |http|
283
- # # always proxy via your.proxy.addr:8080
284
- # }
284
+ # Net::HTTP.new('example.com', nil, proxy_addr, proxy_port).start { |http|
285
+ # # always proxy via your.proxy.addr:8080
286
+ # }
285
287
  #
286
288
  # See Net::HTTP.new for further details and examples such as proxies that
287
289
  # require a username and password.
288
290
  #
289
- # === Compression
291
+ # ### Compression
290
292
  #
291
293
  # Net::HTTP automatically adds Accept-Encoding for compression of response
292
294
  # bodies and automatically decompresses gzip and deflate responses unless a
@@ -294,93 +296,170 @@ module Net
294
296
  #
295
297
  # Compression can be disabled through the Accept-Encoding: identity header.
296
298
  #
297
- # == HTTP Request Classes
299
+ # ## HTTP Request Classes
298
300
  #
299
301
  # Here is the HTTP request class hierarchy.
300
302
  #
301
- # * Net::HTTPRequest
302
- # * Net::HTTP::Get
303
- # * Net::HTTP::Head
304
- # * Net::HTTP::Post
305
- # * Net::HTTP::Patch
306
- # * Net::HTTP::Put
307
- # * Net::HTTP::Proppatch
308
- # * Net::HTTP::Lock
309
- # * Net::HTTP::Unlock
310
- # * Net::HTTP::Options
311
- # * Net::HTTP::Propfind
312
- # * Net::HTTP::Delete
313
- # * Net::HTTP::Move
314
- # * Net::HTTP::Copy
315
- # * Net::HTTP::Mkcol
316
- # * Net::HTTP::Trace
317
- #
318
- # == HTTP Response Classes
319
- #
320
- # Here is HTTP response class hierarchy. All classes are defined in Net
321
- # module and are subclasses of Net::HTTPResponse.
322
- #
323
- # HTTPUnknownResponse:: For unhandled HTTP extensions
324
- # HTTPInformation:: 1xx
325
- # HTTPContinue:: 100
326
- # HTTPSwitchProtocol:: 101
327
- # HTTPSuccess:: 2xx
328
- # HTTPOK:: 200
329
- # HTTPCreated:: 201
330
- # HTTPAccepted:: 202
331
- # HTTPNonAuthoritativeInformation:: 203
332
- # HTTPNoContent:: 204
333
- # HTTPResetContent:: 205
334
- # HTTPPartialContent:: 206
335
- # HTTPMultiStatus:: 207
336
- # HTTPIMUsed:: 226
337
- # HTTPRedirection:: 3xx
338
- # HTTPMultipleChoices:: 300
339
- # HTTPMovedPermanently:: 301
340
- # HTTPFound:: 302
341
- # HTTPSeeOther:: 303
342
- # HTTPNotModified:: 304
343
- # HTTPUseProxy:: 305
344
- # HTTPTemporaryRedirect:: 307
345
- # HTTPClientError:: 4xx
346
- # HTTPBadRequest:: 400
347
- # HTTPUnauthorized:: 401
348
- # HTTPPaymentRequired:: 402
349
- # HTTPForbidden:: 403
350
- # HTTPNotFound:: 404
351
- # HTTPMethodNotAllowed:: 405
352
- # HTTPNotAcceptable:: 406
353
- # HTTPProxyAuthenticationRequired:: 407
354
- # HTTPRequestTimeOut:: 408
355
- # HTTPConflict:: 409
356
- # HTTPGone:: 410
357
- # HTTPLengthRequired:: 411
358
- # HTTPPreconditionFailed:: 412
359
- # HTTPRequestEntityTooLarge:: 413
360
- # HTTPRequestURITooLong:: 414
361
- # HTTPUnsupportedMediaType:: 415
362
- # HTTPRequestedRangeNotSatisfiable:: 416
363
- # HTTPExpectationFailed:: 417
364
- # HTTPUnprocessableEntity:: 422
365
- # HTTPLocked:: 423
366
- # HTTPFailedDependency:: 424
367
- # HTTPUpgradeRequired:: 426
368
- # HTTPPreconditionRequired:: 428
369
- # HTTPTooManyRequests:: 429
370
- # HTTPRequestHeaderFieldsTooLarge:: 431
371
- # HTTPUnavailableForLegalReasons:: 451
372
- # HTTPServerError:: 5xx
373
- # HTTPInternalServerError:: 500
374
- # HTTPNotImplemented:: 501
375
- # HTTPBadGateway:: 502
376
- # HTTPServiceUnavailable:: 503
377
- # HTTPGatewayTimeOut:: 504
378
- # HTTPVersionNotSupported:: 505
379
- # HTTPInsufficientStorage:: 507
380
- # HTTPNetworkAuthenticationRequired:: 511
381
- #
382
- # There is also the Net::HTTPBadResponse exception which is raised when
383
- # there is a protocol error.
303
+ # * Net::HTTPRequest
304
+ # * Net::HTTP::Get
305
+ # * Net::HTTP::Head
306
+ # * Net::HTTP::Post
307
+ # * Net::HTTP::Patch
308
+ # * Net::HTTP::Put
309
+ # * Net::HTTP::Proppatch
310
+ # * Net::HTTP::Lock
311
+ # * Net::HTTP::Unlock
312
+ # * Net::HTTP::Options
313
+ # * Net::HTTP::Propfind
314
+ # * Net::HTTP::Delete
315
+ # * Net::HTTP::Move
316
+ # * Net::HTTP::Copy
317
+ # * Net::HTTP::Mkcol
318
+ # * Net::HTTP::Trace
319
+ #
320
+ #
321
+ #
322
+ # ## HTTP Response Classes
323
+ #
324
+ # Here is HTTP response class hierarchy. All classes are defined in Net module
325
+ # and are subclasses of Net::HTTPResponse.
326
+ #
327
+ # HTTPUnknownResponse
328
+ # : For unhandled HTTP extensions
329
+ # HTTPInformation
330
+ # : 1xx
331
+ # HTTPContinue
332
+ # : 100
333
+ # HTTPSwitchProtocol
334
+ # : 101
335
+ # HTTPProcessing
336
+ # : 102
337
+ # HTTPEarlyHints
338
+ # : 103
339
+ # HTTPSuccess
340
+ # : 2xx
341
+ # HTTPOK
342
+ # : 200
343
+ # HTTPCreated
344
+ # : 201
345
+ # HTTPAccepted
346
+ # : 202
347
+ # HTTPNonAuthoritativeInformation
348
+ # : 203
349
+ # HTTPNoContent
350
+ # : 204
351
+ # HTTPResetContent
352
+ # : 205
353
+ # HTTPPartialContent
354
+ # : 206
355
+ # HTTPMultiStatus
356
+ # : 207
357
+ # HTTPAlreadyReported
358
+ # : 208
359
+ # HTTPIMUsed
360
+ # : 226
361
+ # HTTPRedirection
362
+ # : 3xx
363
+ # HTTPMultipleChoices
364
+ # : 300
365
+ # HTTPMovedPermanently
366
+ # : 301
367
+ # HTTPFound
368
+ # : 302
369
+ # HTTPSeeOther
370
+ # : 303
371
+ # HTTPNotModified
372
+ # : 304
373
+ # HTTPUseProxy
374
+ # : 305
375
+ # HTTPTemporaryRedirect
376
+ # : 307
377
+ # HTTPPermanentRedirect
378
+ # : 308
379
+ # HTTPClientError
380
+ # : 4xx
381
+ # HTTPBadRequest
382
+ # : 400
383
+ # HTTPUnauthorized
384
+ # : 401
385
+ # HTTPPaymentRequired
386
+ # : 402
387
+ # HTTPForbidden
388
+ # : 403
389
+ # HTTPNotFound
390
+ # : 404
391
+ # HTTPMethodNotAllowed
392
+ # : 405
393
+ # HTTPNotAcceptable
394
+ # : 406
395
+ # HTTPProxyAuthenticationRequired
396
+ # : 407
397
+ # HTTPRequestTimeOut
398
+ # : 408
399
+ # HTTPConflict
400
+ # : 409
401
+ # HTTPGone
402
+ # : 410
403
+ # HTTPLengthRequired
404
+ # : 411
405
+ # HTTPPreconditionFailed
406
+ # : 412
407
+ # HTTPRequestEntityTooLarge
408
+ # : 413
409
+ # HTTPRequestURITooLong
410
+ # : 414
411
+ # HTTPUnsupportedMediaType
412
+ # : 415
413
+ # HTTPRequestedRangeNotSatisfiable
414
+ # : 416
415
+ # HTTPExpectationFailed
416
+ # : 417
417
+ # HTTPMisdirectedRequest
418
+ # : 421
419
+ # HTTPUnprocessableEntity
420
+ # : 422
421
+ # HTTPLocked
422
+ # : 423
423
+ # HTTPFailedDependency
424
+ # : 424
425
+ # HTTPUpgradeRequired
426
+ # : 426
427
+ # HTTPPreconditionRequired
428
+ # : 428
429
+ # HTTPTooManyRequests
430
+ # : 429
431
+ # HTTPRequestHeaderFieldsTooLarge
432
+ # : 431
433
+ # HTTPUnavailableForLegalReasons
434
+ # : 451
435
+ # HTTPServerError
436
+ # : 5xx
437
+ # HTTPInternalServerError
438
+ # : 500
439
+ # HTTPNotImplemented
440
+ # : 501
441
+ # HTTPBadGateway
442
+ # : 502
443
+ # HTTPServiceUnavailable
444
+ # : 503
445
+ # HTTPGatewayTimeOut
446
+ # : 504
447
+ # HTTPVersionNotSupported
448
+ # : 505
449
+ # HTTPVariantAlsoNegotiates
450
+ # : 506
451
+ # HTTPInsufficientStorage
452
+ # : 507
453
+ # HTTPLoopDetected
454
+ # : 508
455
+ # HTTPNotExtended
456
+ # : 510
457
+ # HTTPNetworkAuthenticationRequired
458
+ # : 511
459
+ #
460
+ #
461
+ # There is also the Net::HTTPBadResponse exception which is raised when there is
462
+ # a protocol error.
384
463
  #
385
464
  class HTTP < Protocol
386
465
  # :stopdoc:
@@ -392,383 +471,621 @@ module Net
392
471
 
393
472
  HAVE_ZLIB: bool
394
473
 
395
- # Turns on net/http 1.2 (Ruby 1.8) features.
396
- # Defaults to ON in Ruby 1.8 or later.
474
+ # <!--
475
+ # rdoc-file=lib/net/http.rb
476
+ # - version_1_2()
477
+ # -->
478
+ # Turns on net/http 1.2 (Ruby 1.8) features. Defaults to ON in Ruby 1.8 or
479
+ # later.
480
+ #
397
481
  def self.version_1_2: () -> ::TrueClass
398
482
 
399
- # Returns true if net/http is in version 1.2 mode.
400
- # Defaults to true.
483
+ # <!--
484
+ # rdoc-file=lib/net/http.rb
485
+ # - version_1_2?()
486
+ # -->
487
+ # Returns true if net/http is in version 1.2 mode. Defaults to true.
488
+ #
401
489
  def self.version_1_2?: () -> ::TrueClass
402
490
 
403
491
  def self.version_1_1?: () -> ::FalseClass
404
492
 
405
493
  alias self.is_version_1_1? self.version_1_1?
406
494
 
495
+ # <!--
496
+ # rdoc-file=lib/net/http.rb
497
+ # - is_version_1_2?()
498
+ # -->
499
+ #
407
500
  alias self.is_version_1_2? self.version_1_2?
408
501
 
502
+ # <!--
503
+ # rdoc-file=lib/net/http.rb
504
+ # - get_print(uri_or_host, path_or_headers = nil, port = nil)
505
+ # -->
506
+ # Gets the body text from the target and outputs it to $stdout. The target can
507
+ # either be specified as (`uri`, `headers`), or as (`host`, `path`, `port` =
508
+ # 80); so:
409
509
  #
410
- # Gets the body text from the target and outputs it to $stdout. The
411
- # target can either be specified as
412
- # (+uri+, +headers+), or as (+host+, +path+, +port+ = 80); so:
413
- #
414
- # Net::HTTP.get_print URI('http://www.example.com/index.html')
510
+ # Net::HTTP.get_print URI('http://www.example.com/index.html')
415
511
  #
416
512
  # or:
417
513
  #
418
- # Net::HTTP.get_print 'www.example.com', '/index.html'
514
+ # Net::HTTP.get_print 'www.example.com', '/index.html'
419
515
  #
420
516
  # you can also specify request headers:
421
517
  #
422
- # Net::HTTP.get_print URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' }
518
+ # Net::HTTP.get_print URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' }
423
519
  #
424
520
  def self.get_print: (URI::Generic uri, ?Hash[String, untyped] header) -> void
425
521
  | (String host, String path, ?Integer port) -> void
426
522
 
427
- # Sends a GET request to the target and returns the HTTP response
428
- # as a string. The target can either be specified as
429
- # (+uri+, +headers+), or as (+host+, +path+, +port+ = 80); so:
523
+ # <!--
524
+ # rdoc-file=lib/net/http.rb
525
+ # - get(uri_or_host, path_or_headers = nil, port = nil)
526
+ # -->
527
+ # Sends a GET request to the target and returns the HTTP response as a string.
528
+ # The target can either be specified as (`uri`, `headers`), or as (`host`,
529
+ # `path`, `port` = 80); so:
430
530
  #
431
- # print Net::HTTP.get(URI('http://www.example.com/index.html'))
531
+ # print Net::HTTP.get(URI('http://www.example.com/index.html'))
432
532
  #
433
533
  # or:
434
534
  #
435
- # print Net::HTTP.get('www.example.com', '/index.html')
535
+ # print Net::HTTP.get('www.example.com', '/index.html')
436
536
  #
437
537
  # you can also specify request headers:
438
538
  #
439
- # Net::HTTP.get(URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' })
539
+ # Net::HTTP.get(URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' })
440
540
  #
441
541
  def self.get: (URI::Generic uri, ?Hash[String, untyped] header) -> String
442
542
  | (String host, String path, ?Integer port) -> String
443
543
 
444
-
445
- # Sends a GET request to the target and returns the HTTP response
446
- # as a Net::HTTPResponse object. The target can either be specified as
447
- # (+uri+, +headers+), or as (+host+, +path+, +port+ = 80); so:
544
+ # <!--
545
+ # rdoc-file=lib/net/http.rb
546
+ # - get_response(uri_or_host, path_or_headers = nil, port = nil, &block)
547
+ # -->
548
+ # Sends a GET request to the target and returns the HTTP response as a
549
+ # Net::HTTPResponse object. The target can either be specified as (`uri`,
550
+ # `headers`), or as (`host`, `path`, `port` = 80); so:
448
551
  #
449
- # res = Net::HTTP.get_response(URI('http://www.example.com/index.html'))
450
- # print res.body
552
+ # res = Net::HTTP.get_response(URI('http://www.example.com/index.html'))
553
+ # print res.body
451
554
  #
452
555
  # or:
453
556
  #
454
- # res = Net::HTTP.get_response('www.example.com', '/index.html')
455
- # print res.body
557
+ # res = Net::HTTP.get_response('www.example.com', '/index.html')
558
+ # print res.body
456
559
  #
457
560
  # you can also specify request headers:
458
561
  #
459
- # Net::HTTP.get_response(URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' })
562
+ # Net::HTTP.get_response(URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' })
460
563
  #
461
564
  def self.get_response: (URI::Generic uri, ?Hash[String, untyped] header) ?{ (Net::HTTPResponse) -> void } -> Net::HTTPResponse
462
565
  | (String host, String path, ?Integer port) -> Net::HTTPResponse
463
566
 
567
+ # <!--
568
+ # rdoc-file=lib/net/http.rb
569
+ # - post(url, data, header = nil)
570
+ # -->
464
571
  # Posts data to the specified URI object.
465
572
  #
466
573
  # Example:
467
574
  #
468
- # require 'net/http'
469
- # require 'uri'
575
+ # require 'net/http'
576
+ # require 'uri'
470
577
  #
471
- # Net::HTTP.post URI('http://www.example.com/api/search'),
472
- # { "q" => "ruby", "max" => "50" }.to_json,
473
- # "Content-Type" => "application/json"
578
+ # Net::HTTP.post URI('http://www.example.com/api/search'),
579
+ # { "q" => "ruby", "max" => "50" }.to_json,
580
+ # "Content-Type" => "application/json"
474
581
  #
475
582
  def self.post: (URI::Generic url, String data, ?Hash[String, untyped] header) -> Net::HTTPResponse
476
583
 
477
- # Posts HTML form data to the specified URI object.
478
- # The form data must be provided as a Hash mapping from String to String.
479
- # Example:
584
+ # <!--
585
+ # rdoc-file=lib/net/http.rb
586
+ # - post_form(url, params)
587
+ # -->
588
+ # Posts HTML form data to the specified URI object. The form data must be
589
+ # provided as a Hash mapping from String to String. Example:
480
590
  #
481
- # { "cmd" => "search", "q" => "ruby", "max" => "50" }
591
+ # { "cmd" => "search", "q" => "ruby", "max" => "50" }
482
592
  #
483
- # This method also does Basic Authentication if and only if +url+.user exists.
484
- # But userinfo for authentication is deprecated (RFC3986).
485
- # So this feature will be removed.
593
+ # This method also does Basic Authentication if and only if `url`.user exists.
594
+ # But userinfo for authentication is deprecated (RFC3986). So this feature will
595
+ # be removed.
486
596
  #
487
597
  # Example:
488
598
  #
489
- # require 'net/http'
599
+ # require 'net/http'
490
600
  #
491
- # Net::HTTP.post_form URI('http://www.example.com/search.cgi'),
492
- # { "q" => "ruby", "max" => "50" }
601
+ # Net::HTTP.post_form URI('http://www.example.com/search.cgi'),
602
+ # { "q" => "ruby", "max" => "50" }
493
603
  #
494
604
  def self.post_form: (URI::Generic url, Hash[String, untyped] params) -> Net::HTTPResponse
495
605
 
606
+ # <!--
607
+ # rdoc-file=lib/net/http.rb
608
+ # - default_port()
609
+ # -->
496
610
  # The default port to use for HTTP requests; defaults to 80.
611
+ #
497
612
  def self.default_port: () -> Integer
498
613
 
614
+ # <!--
615
+ # rdoc-file=lib/net/http.rb
616
+ # - http_default_port()
617
+ # -->
499
618
  # The default port to use for HTTP requests; defaults to 80.
619
+ #
500
620
  def self.http_default_port: () -> Integer
501
621
 
622
+ # <!--
623
+ # rdoc-file=lib/net/http.rb
624
+ # - https_default_port()
625
+ # -->
502
626
  # The default port to use for HTTPS requests; defaults to 443.
627
+ #
503
628
  def self.https_default_port: () -> Integer
504
629
 
630
+ # <!--
631
+ # rdoc-file=lib/net/http.rb
632
+ # - HTTP.start(address, port, p_addr, p_port, p_user, p_pass, &block)
633
+ # - HTTP.start(address, port=nil, p_addr=:ENV, p_port=nil, p_user=nil, p_pass=nil, opt, &block)
634
+ # -->
635
+ # Creates a new Net::HTTP object, then additionally opens the TCP connection and
636
+ # HTTP session.
637
+ #
638
+ # Arguments are the following:
639
+ # *address*
640
+ # : hostname or IP address of the server
641
+ # *port*
642
+ # : port of the server
643
+ # *p_addr*
644
+ # : address of proxy
645
+ # *p_port*
646
+ # : port of proxy
647
+ # *p_user*
648
+ # : user of proxy
649
+ # *p_pass*
650
+ # : pass of proxy
651
+ # *opt*
652
+ # : optional hash
653
+ #
654
+ #
655
+ # *opt* sets following values by its accessor. The keys are ipaddr, ca_file,
656
+ # ca_path, cert, cert_store, ciphers, keep_alive_timeout,
657
+ # close_on_empty_response, key, open_timeout, read_timeout, write_timeout,
658
+ # ssl_timeout, ssl_version, use_ssl, verify_callback, verify_depth and
659
+ # verify_mode. If you set :use_ssl as true, you can use https and default value
660
+ # of verify_mode is set as OpenSSL::SSL::VERIFY_PEER.
661
+ #
662
+ # If the optional block is given, the newly created Net::HTTP object is passed
663
+ # to it and closed when the block finishes. In this case, the return value of
664
+ # this method is the return value of the block. If no block is given, the
665
+ # return value of this method is the newly created Net::HTTP object itself, and
666
+ # the caller is responsible for closing it upon completion using the finish()
667
+ # method.
668
+ #
505
669
  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
506
670
  | [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
507
671
 
672
+ # <!--
673
+ # rdoc-file=lib/net/http.rb
674
+ # - newobj(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil)
675
+ # -->
676
+ #
508
677
  alias self.newobj self.new
509
678
 
510
- # Creates a new Net::HTTP object without opening a TCP connection or
511
- # HTTP session.
512
- #
513
- # The +address+ should be a DNS hostname or IP address, the +port+ is the
514
- # port the server operates on. If no +port+ is given the default port for
515
- # HTTP or HTTPS is used.
516
- #
517
- # If none of the +p_+ arguments are given, the proxy host and port are
518
- # taken from the +http_proxy+ environment variable (or its uppercase
519
- # equivalent) if present. If the proxy requires authentication you must
520
- # supply it by hand. See URI::Generic#find_proxy for details of proxy
521
- # detection from the environment. To disable proxy detection set +p_addr+
522
- # to nil.
523
- #
524
- # If you are connecting to a custom proxy, +p_addr+ specifies the DNS name
525
- # or IP address of the proxy host, +p_port+ the port to use to access the
526
- # proxy, +p_user+ and +p_pass+ the username and password if authorization
527
- # is required to use the proxy, and p_no_proxy hosts which do not
528
- # use the proxy.
679
+ # <!--
680
+ # rdoc-file=lib/net/http.rb
681
+ # - new(address, port = nil)
682
+ # -->
683
+ # Creates a new Net::HTTP object for the specified server address, without
684
+ # opening the TCP connection or initializing the HTTP session. The `address`
685
+ # should be a DNS hostname or IP address.
529
686
  #
530
687
  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
531
688
 
689
+ # <!--
690
+ # rdoc-file=lib/net/http.rb
691
+ # - inspect()
692
+ # -->
693
+ #
532
694
  def inspect: () -> String
533
695
 
534
- # *WARNING* This method opens a serious security hole.
535
- # Never use this method in production code.
696
+ # <!--
697
+ # rdoc-file=lib/net/http.rb
698
+ # - set_debug_output(output)
699
+ # -->
700
+ # **WARNING** This method opens a serious security hole. Never use this method
701
+ # in production code.
536
702
  #
537
703
  # Sets an output stream for debugging.
538
704
  #
539
- # http = Net::HTTP.new(hostname)
540
- # http.set_debug_output $stderr
541
- # http.start { .... }
705
+ # http = Net::HTTP.new(hostname)
706
+ # http.set_debug_output $stderr
707
+ # http.start { .... }
542
708
  #
543
709
  def set_debug_output: (IO output) -> void
544
710
 
711
+ # <!-- rdoc-file=lib/net/http.rb -->
545
712
  # The DNS host name or IP address to connect to.
713
+ #
546
714
  attr_reader address: String
547
715
 
716
+ # <!-- rdoc-file=lib/net/http.rb -->
548
717
  # The port number to connect to.
718
+ #
549
719
  attr_reader port: Integer
550
720
 
721
+ # <!-- rdoc-file=lib/net/http.rb -->
551
722
  # The local host used to establish the connection.
723
+ #
552
724
  attr_accessor local_host: String
553
725
 
726
+ # <!-- rdoc-file=lib/net/http.rb -->
554
727
  # The local port used to establish the connection.
728
+ #
555
729
  attr_accessor local_port: Integer
556
730
 
557
731
  attr_writer proxy_from_env: untyped
558
732
 
733
+ # <!-- rdoc-file=lib/net/http.rb -->
734
+ #
559
735
  attr_accessor proxy_address: String?
560
736
 
737
+ # <!-- rdoc-file=lib/net/http.rb -->
738
+ #
561
739
  attr_accessor proxy_port: Integer?
562
740
 
741
+ # <!-- rdoc-file=lib/net/http.rb -->
742
+ #
563
743
  attr_accessor proxy_user: String?
564
744
 
745
+ # <!-- rdoc-file=lib/net/http.rb -->
746
+ #
565
747
  attr_accessor proxy_pass: String?
566
748
 
749
+ # <!--
750
+ # rdoc-file=lib/net/http.rb
751
+ # - ipaddr()
752
+ # -->
567
753
  # The IP address to connect to/used to connect to
754
+ # ----
755
+ # <!--
756
+ # rdoc-file=lib/net/http.rb
757
+ # - ipaddr=(addr)
758
+ # -->
568
759
  # Set the IP address to connect to
760
+ #
569
761
  attr_accessor ipaddr: String?
570
762
 
571
- # Number of seconds to wait for the connection to open. Any number
572
- # may be used, including Floats for fractional seconds. If the HTTP
573
- # object cannot open a connection in this many seconds, it raises a
574
- # Net::OpenTimeout exception. The default value is 60 seconds.
575
- attr_accessor open_timeout: (Float | Integer)
576
-
577
- # Number of seconds to wait for one block to be read (via one read(2)
578
- # call). Any number may be used, including Floats for fractional
579
- # seconds. If the HTTP object cannot read data in this many seconds,
580
- # it raises a Net::ReadTimeout exception. The default value is 60 seconds.
763
+ # <!-- rdoc-file=lib/net/http.rb -->
764
+ # Number of seconds to wait for the connection to open. Any number may be used,
765
+ # including Floats for fractional seconds. If the HTTP object cannot open a
766
+ # connection in this many seconds, it raises a Net::OpenTimeout exception. The
767
+ # default value is 60 seconds.
768
+ #
769
+ attr_accessor open_timeout: Float | Integer
770
+
771
+ # <!-- rdoc-file=lib/net/http.rb -->
772
+ # Number of seconds to wait for one block to be read (via one read(2) call). Any
773
+ # number may be used, including Floats for fractional seconds. If the HTTP
774
+ # object cannot read data in this many seconds, it raises a Net::ReadTimeout
775
+ # exception. The default value is 60 seconds.
776
+ # ----
777
+ # <!--
778
+ # rdoc-file=lib/net/http.rb
779
+ # - read_timeout=(sec)
780
+ # -->
581
781
  # Setter for the read_timeout attribute.
582
- attr_accessor read_timeout: (Float | Integer)
583
-
584
- # Number of seconds to wait for one block to be written (via one write(2)
585
- # call). Any number may be used, including Floats for fractional
586
- # seconds. If the HTTP object cannot write data in this many seconds,
587
- # it raises a Net::WriteTimeout exception. The default value is 60 seconds.
588
- # Net::WriteTimeout is not raised on Windows.
782
+ #
783
+ attr_accessor read_timeout: Float | Integer
784
+
785
+ # <!-- rdoc-file=lib/net/http.rb -->
786
+ # Number of seconds to wait for one block to be written (via one write(2) call).
787
+ # Any number may be used, including Floats for fractional seconds. If the HTTP
788
+ # object cannot write data in this many seconds, it raises a Net::WriteTimeout
789
+ # exception. The default value is 60 seconds. Net::WriteTimeout is not raised on
790
+ # Windows.
791
+ # ----
792
+ # <!--
793
+ # rdoc-file=lib/net/http.rb
794
+ # - write_timeout=(sec)
795
+ # -->
589
796
  # Setter for the write_timeout attribute.
590
- attr_accessor write_timeout: (Float | Integer)
797
+ #
798
+ attr_accessor write_timeout: Float | Integer
591
799
 
800
+ # <!--
801
+ # rdoc-file=lib/net/http.rb
802
+ # - max_retries=(retries)
803
+ # -->
592
804
  # Maximum number of times to retry an idempotent request in case of
593
- # Net::ReadTimeout, IOError, EOFError, Errno::ECONNRESET,
594
- # Errno::ECONNABORTED, Errno::EPIPE, OpenSSL::SSL::SSLError,
595
- # Timeout::Error.
596
- # Should be a non-negative integer number. Zero means no retries.
597
- # The default value is 1.
805
+ # Net::ReadTimeout, IOError, EOFError, Errno::ECONNRESET, Errno::ECONNABORTED,
806
+ # Errno::EPIPE, OpenSSL::SSL::SSLError, Timeout::Error. Should be a non-negative
807
+ # integer number. Zero means no retries. The default value is 1.
808
+ #
598
809
  attr_accessor max_retries: Integer
599
810
 
600
- # Seconds to wait for 100 Continue response. If the HTTP object does not
601
- # receive a response in this many seconds it sends the request body. The
602
- # default value is +nil+.
811
+ # <!-- rdoc-file=lib/net/http.rb -->
812
+ # Seconds to wait for 100 Continue response. If the HTTP object does not receive
813
+ # a response in this many seconds it sends the request body. The default value
814
+ # is `nil`.
815
+ # ----
816
+ # <!--
817
+ # rdoc-file=lib/net/http.rb
818
+ # - continue_timeout=(sec)
819
+ # -->
603
820
  # Setter for the continue_timeout attribute.
604
- attr_accessor continue_timeout: (Float | Integer | nil)
821
+ #
822
+ attr_accessor continue_timeout: Float | Integer | nil
605
823
 
606
- # Seconds to reuse the connection of the previous request.
607
- # If the idle time is less than this Keep-Alive Timeout,
608
- # Net::HTTP reuses the TCP/IP socket used by the previous communication.
609
- # The default value is 2 seconds.
610
- attr_accessor keep_alive_timeout: (Float | Integer)
824
+ # <!-- rdoc-file=lib/net/http.rb -->
825
+ # Seconds to reuse the connection of the previous request. If the idle time is
826
+ # less than this Keep-Alive Timeout, Net::HTTP reuses the TCP/IP socket used by
827
+ # the previous communication. The default value is 2 seconds.
828
+ #
829
+ attr_accessor keep_alive_timeout: Float | Integer
611
830
 
831
+ # <!--
832
+ # rdoc-file=lib/net/http.rb
833
+ # - started?()
834
+ # -->
612
835
  # Returns true if the HTTP session has been started.
836
+ #
613
837
  def started?: () -> bool
614
838
 
839
+ # <!--
840
+ # rdoc-file=lib/net/http.rb
841
+ # - active?()
842
+ # -->
843
+ #
615
844
  alias active? started?
616
845
 
617
846
  attr_accessor close_on_empty_response: untyped
618
847
 
848
+ # <!--
849
+ # rdoc-file=lib/net/http.rb
850
+ # - use_ssl?()
851
+ # -->
619
852
  # Returns true if SSL/TLS is being used with HTTP.
853
+ #
620
854
  def use_ssl?: () -> bool
621
855
 
622
- # Turn on/off SSL.
623
- # This flag must be set before starting session.
624
- # If you change use_ssl value after session started,
625
- # a Net::HTTP object raises IOError.
856
+ # <!--
857
+ # rdoc-file=lib/net/http.rb
858
+ # - use_ssl=(flag)
859
+ # -->
860
+ # Turn on/off SSL. This flag must be set before starting session. If you change
861
+ # use_ssl value after session started, a Net::HTTP object raises IOError.
862
+ #
626
863
  def use_ssl=: (boolish flag) -> void
627
864
 
628
865
  SSL_IVNAMES: Array[untyped]
629
866
 
630
867
  SSL_ATTRIBUTES: Array[Symbol]
631
868
 
869
+ # <!-- rdoc-file=lib/net/http.rb -->
632
870
  # Sets path of a CA certification file in PEM format.
633
871
  #
634
872
  # The file can contain several CA certificates.
873
+ #
635
874
  attr_accessor ca_file: untyped
636
875
 
637
- # Sets path of a CA certification directory containing certifications in
638
- # PEM format.
876
+ # <!-- rdoc-file=lib/net/http.rb -->
877
+ # Sets path of a CA certification directory containing certifications in PEM
878
+ # format.
879
+ #
639
880
  attr_accessor ca_path: untyped
640
881
 
641
- # Sets an OpenSSL::X509::Certificate object as client certificate.
642
- # (This method is appeared in Michal Rokos's OpenSSL extension).
882
+ # <!-- rdoc-file=lib/net/http.rb -->
883
+ # Sets an OpenSSL::X509::Certificate object as client certificate. (This method
884
+ # is appeared in Michal Rokos's OpenSSL extension).
885
+ #
643
886
  attr_accessor cert: untyped
644
887
 
888
+ # <!-- rdoc-file=lib/net/http.rb -->
645
889
  # Sets the X509::Store to verify peer certificate.
890
+ #
646
891
  attr_accessor cert_store: untyped
647
892
 
893
+ # <!-- rdoc-file=lib/net/http.rb -->
648
894
  # Sets the available ciphers. See OpenSSL::SSL::SSLContext#ciphers=
895
+ #
649
896
  attr_accessor ciphers: untyped
650
897
 
651
- # Sets the extra X509 certificates to be added to the certificate chain.
652
- # See OpenSSL::SSL::SSLContext#extra_chain_cert=
898
+ # <!-- rdoc-file=lib/net/http.rb -->
899
+ # Sets the extra X509 certificates to be added to the certificate chain. See
900
+ # OpenSSL::SSL::SSLContext#extra_chain_cert=
901
+ #
653
902
  attr_accessor extra_chain_cert: untyped
654
903
 
655
- # Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
656
- # (This method is appeared in Michal Rokos's OpenSSL extension.)
904
+ # <!-- rdoc-file=lib/net/http.rb -->
905
+ # Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object. (This method is
906
+ # appeared in Michal Rokos's OpenSSL extension.)
907
+ #
657
908
  attr_accessor key: untyped
658
909
 
910
+ # <!-- rdoc-file=lib/net/http.rb -->
659
911
  # Sets the SSL timeout seconds.
912
+ #
660
913
  attr_accessor ssl_timeout: untyped
661
914
 
915
+ # <!-- rdoc-file=lib/net/http.rb -->
662
916
  # Sets the SSL version. See OpenSSL::SSL::SSLContext#ssl_version=
917
+ #
663
918
  attr_accessor ssl_version: untyped
664
919
 
920
+ # <!-- rdoc-file=lib/net/http.rb -->
665
921
  # Sets the minimum SSL version. See OpenSSL::SSL::SSLContext#min_version=
922
+ #
666
923
  attr_accessor min_version: untyped
667
924
 
925
+ # <!-- rdoc-file=lib/net/http.rb -->
668
926
  # Sets the maximum SSL version. See OpenSSL::SSL::SSLContext#max_version=
927
+ #
669
928
  attr_accessor max_version: untyped
670
929
 
930
+ # <!-- rdoc-file=lib/net/http.rb -->
671
931
  # Sets the verify callback for the server certification verification.
932
+ #
672
933
  attr_accessor verify_callback: untyped
673
934
 
935
+ # <!-- rdoc-file=lib/net/http.rb -->
674
936
  # Sets the maximum depth for the certificate chain verification.
937
+ #
675
938
  attr_accessor verify_depth: untyped
676
939
 
940
+ # <!-- rdoc-file=lib/net/http.rb -->
677
941
  # Sets the flags for server the certification verification at beginning of
678
942
  # SSL/TLS session.
679
943
  #
680
944
  # OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER are acceptable.
945
+ #
681
946
  attr_accessor verify_mode: untyped
682
947
 
683
- # Sets to check the server certificate is valid for the hostname.
684
- # See OpenSSL::SSL::SSLContext#verify_hostname=
948
+ # <!-- rdoc-file=lib/net/http.rb -->
949
+ # Sets to check the server certificate is valid for the hostname. See
950
+ # OpenSSL::SSL::SSLContext#verify_hostname=
951
+ #
685
952
  attr_accessor verify_hostname: untyped
686
953
 
954
+ # <!--
955
+ # rdoc-file=lib/net/http.rb
956
+ # - peer_cert()
957
+ # -->
687
958
  # Returns the X.509 certificates the server presented.
959
+ #
688
960
  def peer_cert: () -> (nil | untyped)
689
961
 
962
+ # <!--
963
+ # rdoc-file=lib/net/http.rb
964
+ # - start() { |http| ... }
965
+ # -->
690
966
  # Opens a TCP connection and HTTP session.
691
967
  #
692
- # When this method is called with a block, it passes the Net::HTTP
693
- # object to the block, and closes the TCP connection and HTTP session
694
- # after the block has been executed.
968
+ # When this method is called with a block, it passes the Net::HTTP object to the
969
+ # block, and closes the TCP connection and HTTP session after the block has been
970
+ # executed.
695
971
  #
696
- # When called with a block, it returns the return value of the
697
- # block; otherwise, it returns self.
972
+ # When called with a block, it returns the return value of the block; otherwise,
973
+ # it returns self.
698
974
  #
699
975
  def start: [T] () { (Net::HTTP) -> T } -> T
700
976
  | () -> Net::HTTP
701
977
 
702
978
  public
703
979
 
704
- # Finishes the HTTP session and closes the TCP connection.
705
- # Raises IOError if the session has not been started.
980
+ # <!--
981
+ # rdoc-file=lib/net/http.rb
982
+ # - finish()
983
+ # -->
984
+ # Finishes the HTTP session and closes the TCP connection. Raises IOError if the
985
+ # session has not been started.
986
+ #
706
987
  def finish: () -> void
707
988
 
708
989
  public
709
990
 
710
- # Creates an HTTP proxy class which behaves like Net::HTTP, but
711
- # performs all access via the specified proxy.
991
+ # <!--
992
+ # rdoc-file=lib/net/http.rb
993
+ # - Proxy(p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil)
994
+ # -->
995
+ # Creates an HTTP proxy class which behaves like Net::HTTP, but performs all
996
+ # access via the specified proxy.
712
997
  #
713
998
  # This class is obsolete. You may pass these same parameters directly to
714
999
  # Net::HTTP.new. See Net::HTTP.new for details of the arguments.
715
- def self.Proxy: (?(Symbol | String) p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass) -> untyped
1000
+ #
1001
+ def self.Proxy: (?Symbol | String p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass) -> untyped
716
1002
 
1003
+ # <!--
1004
+ # rdoc-file=lib/net/http.rb
1005
+ # - proxy_class?()
1006
+ # -->
717
1007
  # returns true if self is a class which was created by HTTP::Proxy.
1008
+ #
718
1009
  def self.proxy_class?: () -> bool
719
1010
 
1011
+ # <!-- rdoc-file=lib/net/http.rb -->
720
1012
  # Address of proxy host. If Net::HTTP does not use a proxy, nil.
1013
+ #
721
1014
  attr_reader self.proxy_address: String?
722
1015
 
1016
+ # <!-- rdoc-file=lib/net/http.rb -->
723
1017
  # Port number of proxy host. If Net::HTTP does not use a proxy, nil.
1018
+ #
724
1019
  attr_reader self.proxy_port: Integer?
725
1020
 
1021
+ # <!-- rdoc-file=lib/net/http.rb -->
726
1022
  # User name for accessing proxy. If Net::HTTP does not use a proxy, nil.
1023
+ #
727
1024
  attr_reader self.proxy_user: String?
728
1025
 
729
- # User password for accessing proxy. If Net::HTTP does not use a proxy,
730
- # nil.
1026
+ # <!-- rdoc-file=lib/net/http.rb -->
1027
+ # User password for accessing proxy. If Net::HTTP does not use a proxy, nil.
1028
+ #
731
1029
  attr_reader self.proxy_pass: String?
732
1030
 
1031
+ # <!--
1032
+ # rdoc-file=lib/net/http.rb
1033
+ # - proxy?()
1034
+ # -->
733
1035
  # True if requests for this connection will be proxied
1036
+ #
734
1037
  def proxy?: () -> bool
735
1038
 
1039
+ # <!--
1040
+ # rdoc-file=lib/net/http.rb
1041
+ # - proxy_from_env?()
1042
+ # -->
736
1043
  # True if the proxy for this connection is determined from the environment
1044
+ #
737
1045
  def proxy_from_env?: () -> bool
738
1046
 
739
1047
  def proxy_uri: () -> (nil | URI::Generic)
740
1048
 
1049
+ # <!--
1050
+ # rdoc-file=lib/net/http.rb
1051
+ # - proxyaddr()
1052
+ # -->
1053
+ #
741
1054
  alias proxyaddr proxy_address
742
1055
 
1056
+ # <!--
1057
+ # rdoc-file=lib/net/http.rb
1058
+ # - proxyport()
1059
+ # -->
1060
+ #
743
1061
  alias proxyport proxy_port
744
1062
 
745
1063
  public
746
1064
 
747
- # Retrieves data from +path+ on the connected-to host which may be an
748
- # absolute path String or a URI to extract the path from.
749
- #
750
- # +initheader+ must be a Hash like { 'Accept' => '*/*', ... },
751
- # and it defaults to an empty hash.
752
- # If +initheader+ doesn't have the key 'accept-encoding', then
753
- # a value of "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" is used,
754
- # so that gzip compression is used in preference to deflate
755
- # compression, which is used in preference to no compression.
756
- # Ruby doesn't have libraries to support the compress (Lempel-Ziv)
757
- # compression, so that is not supported. The intent of this is
758
- # to reduce bandwidth by default. If this routine sets up
759
- # compression, then it does the decompression also, removing
760
- # the header as well to prevent confusion. Otherwise
761
- # it leaves the body as it found it.
1065
+ # <!--
1066
+ # rdoc-file=lib/net/http.rb
1067
+ # - get(path, initheader = nil, dest = nil) { |body_segment| ... }
1068
+ # -->
1069
+ # Retrieves data from `path` on the connected-to host which may be an absolute
1070
+ # path String or a URI to extract the path from.
1071
+ #
1072
+ # `initheader` must be a Hash like { 'Accept' => '**/**', ... }, and it defaults
1073
+ # to an empty hash. If `initheader` doesn't have the key 'accept-encoding', then
1074
+ # a value of "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" is used, so that gzip
1075
+ # compression is used in preference to deflate compression, which is used in
1076
+ # preference to no compression. Ruby doesn't have libraries to support the
1077
+ # compress (Lempel-Ziv) compression, so that is not supported. The intent of
1078
+ # this is to reduce bandwidth by default. If this routine sets up compression,
1079
+ # then it does the decompression also, removing the header as well to prevent
1080
+ # confusion. Otherwise it leaves the body as it found it.
762
1081
  #
763
1082
  # This method returns a Net::HTTPResponse object.
764
1083
  #
765
- # If called with a block, yields each fragment of the
766
- # entity body in turn as a string as it is read from
767
- # the socket. Note that in this case, the returned response
768
- # object will *not* contain a (meaningful) body.
1084
+ # If called with a block, yields each fragment of the entity body in turn as a
1085
+ # string as it is read from the socket. Note that in this case, the returned
1086
+ # response object will **not** contain a (meaningful) body.
769
1087
  #
770
- # +dest+ argument is obsolete.
771
- # It still works but you must not use it.
1088
+ # `dest` argument is obsolete. It still works but you must not use it.
772
1089
  #
773
1090
  # This method never raises an exception.
774
1091
  #
@@ -783,8 +1100,12 @@ module Net
783
1100
  #
784
1101
  def get: (String path, ?Hash[String, untyped] initheader, ?bot dest) ?{ (String body_segment) -> void } -> Net::HTTPResponse
785
1102
 
786
- # Gets only the header from +path+ on the connected-to host.
787
- # +header+ is a Hash like { 'Accept' => '*/*', ... }.
1103
+ # <!--
1104
+ # rdoc-file=lib/net/http.rb
1105
+ # - head(path, initheader = nil)
1106
+ # -->
1107
+ # Gets only the header from `path` on the connected-to host. `header` is a Hash
1108
+ # like { 'Accept' => '**/**', ... }.
788
1109
  #
789
1110
  # This method returns a Net::HTTPResponse object.
790
1111
  #
@@ -798,18 +1119,20 @@ module Net
798
1119
  #
799
1120
  def head: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
800
1121
 
801
- # Posts +data+ (must be a String) to +path+. +header+ must be a Hash
802
- # like { 'Accept' => '*/*', ... }.
1122
+ # <!--
1123
+ # rdoc-file=lib/net/http.rb
1124
+ # - post(path, data, initheader = nil, dest = nil) { |body_segment| ... }
1125
+ # -->
1126
+ # Posts `data` (must be a String) to `path`. `header` must be a Hash like {
1127
+ # 'Accept' => '**/**', ... }.
803
1128
  #
804
1129
  # This method returns a Net::HTTPResponse object.
805
1130
  #
806
- # If called with a block, yields each fragment of the
807
- # entity body in turn as a string as it is read from
808
- # the socket. Note that in this case, the returned response
809
- # object will *not* contain a (meaningful) body.
1131
+ # If called with a block, yields each fragment of the entity body in turn as a
1132
+ # string as it is read from the socket. Note that in this case, the returned
1133
+ # response object will **not** contain a (meaningful) body.
810
1134
  #
811
- # +dest+ argument is obsolete.
812
- # It still works but you must not use it.
1135
+ # `dest` argument is obsolete. It still works but you must not use it.
813
1136
  #
814
1137
  # This method never raises exception.
815
1138
  #
@@ -822,62 +1145,148 @@ module Net
822
1145
  # end
823
1146
  # }
824
1147
  #
825
- # You should set Content-Type: header field for POST.
826
- # If no Content-Type: field given, this method uses
827
- # "application/x-www-form-urlencoded" by default.
1148
+ # You should set Content-Type: header field for POST. If no Content-Type: field
1149
+ # given, this method uses "application/x-www-form-urlencoded" by default.
828
1150
  #
829
1151
  def post: (String path, String data, ?Hash[String, untyped] initheader, ?bot dest) ?{ (String body_segment) -> void } -> Net::HTTPResponse
830
1152
 
831
- # Sends a PATCH request to the +path+ and gets a response,
832
- # as an HTTPResponse object.
1153
+ # <!--
1154
+ # rdoc-file=lib/net/http.rb
1155
+ # - patch(path, data, initheader = nil, dest = nil) { |body_segment| ... }
1156
+ # -->
1157
+ # Sends a PATCH request to the `path` and gets a response, as an HTTPResponse
1158
+ # object.
1159
+ #
833
1160
  def patch: (String path, String data, ?Hash[String, untyped] initheader, ?bot dest) ?{ (String body_segment) -> void } -> Net::HTTPResponse
834
1161
 
835
1162
  def put: (String path, String data, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
836
1163
 
837
- # Sends a PROPPATCH request to the +path+ and gets a response,
838
- # as an HTTPResponse object.
1164
+ # <!--
1165
+ # rdoc-file=lib/net/http.rb
1166
+ # - proppatch(path, body, initheader = nil)
1167
+ # -->
1168
+ # Sends a PROPPATCH request to the `path` and gets a response, as an
1169
+ # HTTPResponse object.
1170
+ #
839
1171
  def proppatch: (String path, String body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
840
1172
 
841
- # Sends a LOCK request to the +path+ and gets a response,
842
- # as an HTTPResponse object.
1173
+ # <!--
1174
+ # rdoc-file=lib/net/http.rb
1175
+ # - lock(path, body, initheader = nil)
1176
+ # -->
1177
+ # Sends a LOCK request to the `path` and gets a response, as an HTTPResponse
1178
+ # object.
1179
+ #
843
1180
  def lock: (String path, String body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
844
1181
 
845
- # Sends a UNLOCK request to the +path+ and gets a response,
846
- # as an HTTPResponse object.
1182
+ # <!--
1183
+ # rdoc-file=lib/net/http.rb
1184
+ # - unlock(path, body, initheader = nil)
1185
+ # -->
1186
+ # Sends a UNLOCK request to the `path` and gets a response, as an HTTPResponse
1187
+ # object.
1188
+ #
847
1189
  def unlock: (String path, String body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
848
1190
 
849
- # Sends a OPTIONS request to the +path+ and gets a response,
850
- # as an HTTPResponse object.
1191
+ # <!--
1192
+ # rdoc-file=lib/net/http.rb
1193
+ # - options(path, initheader = nil)
1194
+ # -->
1195
+ # Sends a OPTIONS request to the `path` and gets a response, as an HTTPResponse
1196
+ # object.
1197
+ #
851
1198
  def options: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
852
1199
 
853
- # Sends a PROPFIND request to the +path+ and gets a response,
854
- # as an HTTPResponse object.
1200
+ # <!--
1201
+ # rdoc-file=lib/net/http.rb
1202
+ # - propfind(path, body = nil, initheader = {'Depth' => '0'})
1203
+ # -->
1204
+ # Sends a PROPFIND request to the `path` and gets a response, as an HTTPResponse
1205
+ # object.
1206
+ #
855
1207
  def propfind: (String path, ?untyped? body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
856
1208
 
857
- # Sends a DELETE request to the +path+ and gets a response,
858
- # as an HTTPResponse object.
1209
+ # <!--
1210
+ # rdoc-file=lib/net/http.rb
1211
+ # - delete(path, initheader = {'Depth' => 'Infinity'})
1212
+ # -->
1213
+ # Sends a DELETE request to the `path` and gets a response, as an HTTPResponse
1214
+ # object.
1215
+ #
859
1216
  def delete: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
860
1217
 
861
- # Sends a MOVE request to the +path+ and gets a response,
862
- # as an HTTPResponse object.
1218
+ # <!--
1219
+ # rdoc-file=lib/net/http.rb
1220
+ # - move(path, initheader = nil)
1221
+ # -->
1222
+ # Sends a MOVE request to the `path` and gets a response, as an HTTPResponse
1223
+ # object.
1224
+ #
863
1225
  def move: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
864
1226
 
865
- # Sends a COPY request to the +path+ and gets a response,
866
- # as an HTTPResponse object.
1227
+ # <!--
1228
+ # rdoc-file=lib/net/http.rb
1229
+ # - copy(path, initheader = nil)
1230
+ # -->
1231
+ # Sends a COPY request to the `path` and gets a response, as an HTTPResponse
1232
+ # object.
1233
+ #
867
1234
  def copy: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
868
1235
 
869
- # Sends a MKCOL request to the +path+ and gets a response,
870
- # as an HTTPResponse object.
1236
+ # <!--
1237
+ # rdoc-file=lib/net/http.rb
1238
+ # - mkcol(path, body = nil, initheader = nil)
1239
+ # -->
1240
+ # Sends a MKCOL request to the `path` and gets a response, as an HTTPResponse
1241
+ # object.
1242
+ #
871
1243
  def mkcol: (String path, ?untyped? body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
872
1244
 
873
- # Sends a TRACE request to the +path+ and gets a response,
874
- # as an HTTPResponse object.
1245
+ # <!--
1246
+ # rdoc-file=lib/net/http.rb
1247
+ # - trace(path, initheader = nil)
1248
+ # -->
1249
+ # Sends a TRACE request to the `path` and gets a response, as an HTTPResponse
1250
+ # object.
1251
+ #
875
1252
  def trace: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
876
1253
 
1254
+ # <!--
1255
+ # rdoc-file=lib/net/http.rb
1256
+ # - request_get(path, initheader = nil) { |response| ... }
1257
+ # -->
1258
+ # Sends a GET request to the `path`. Returns the response as a Net::HTTPResponse
1259
+ # object.
1260
+ #
1261
+ # When called with a block, passes an HTTPResponse object to the block. The body
1262
+ # of the response will not have been read yet; the block can process it using
1263
+ # HTTPResponse#read_body, if desired.
1264
+ #
1265
+ # Returns the response.
1266
+ #
1267
+ # This method never raises Net::* exceptions.
1268
+ #
1269
+ # response = http.request_get('/index.html')
1270
+ # # The entity body is already read in this case.
1271
+ # p response['content-type']
1272
+ # puts response.body
1273
+ #
1274
+ # # Using a block
1275
+ # http.request_get('/index.html') {|response|
1276
+ # p response['content-type']
1277
+ # response.read_body do |str| # read body now
1278
+ # print str
1279
+ # end
1280
+ # }
1281
+ #
877
1282
  def request_get: (String path, ?Hash[String, untyped] initheader) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
878
1283
 
879
- # Sends a HEAD request to the +path+ and returns the response
880
- # as a Net::HTTPResponse object.
1284
+ # <!--
1285
+ # rdoc-file=lib/net/http.rb
1286
+ # - request_head(path, initheader = nil, &block)
1287
+ # -->
1288
+ # Sends a HEAD request to the `path` and returns the response as a
1289
+ # Net::HTTPResponse object.
881
1290
  #
882
1291
  # Returns the response.
883
1292
  #
@@ -888,38 +1297,115 @@ module Net
888
1297
  #
889
1298
  def request_head: (String path, ?Hash[String, untyped] initheader) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
890
1299
 
1300
+ # <!--
1301
+ # rdoc-file=lib/net/http.rb
1302
+ # - request_post(path, data, initheader = nil) { |response| ... }
1303
+ # -->
1304
+ # Sends a POST request to the `path`.
1305
+ #
1306
+ # Returns the response as a Net::HTTPResponse object.
1307
+ #
1308
+ # When called with a block, the block is passed an HTTPResponse object. The
1309
+ # body of that response will not have been read yet; the block can process it
1310
+ # using HTTPResponse#read_body, if desired.
1311
+ #
1312
+ # Returns the response.
1313
+ #
1314
+ # This method never raises Net::* exceptions.
1315
+ #
1316
+ # # example
1317
+ # response = http.request_post('/cgi-bin/nice.rb', 'datadatadata...')
1318
+ # p response.status
1319
+ # puts response.body # body is already read in this case
1320
+ #
1321
+ # # using block
1322
+ # http.request_post('/cgi-bin/nice.rb', 'datadatadata...') {|response|
1323
+ # p response.status
1324
+ # p response['content-type']
1325
+ # response.read_body do |str| # read body now
1326
+ # print str
1327
+ # end
1328
+ # }
1329
+ #
891
1330
  def request_post: (String path, String data, ?Hash[String, untyped] initheader) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
892
1331
 
893
1332
  def request_put: (String path, String data, ?Hash[String, untyped] initheader) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
894
1333
 
1334
+ # <!--
1335
+ # rdoc-file=lib/net/http.rb
1336
+ # - get2(path, initheader = nil)
1337
+ # -->
1338
+ #
895
1339
  alias get2 request_get
896
1340
 
1341
+ # <!--
1342
+ # rdoc-file=lib/net/http.rb
1343
+ # - head2(path, initheader = nil, &block)
1344
+ # -->
1345
+ #
897
1346
  alias head2 request_head
898
1347
 
1348
+ # <!--
1349
+ # rdoc-file=lib/net/http.rb
1350
+ # - post2(path, data, initheader = nil)
1351
+ # -->
1352
+ #
899
1353
  alias post2 request_post
900
1354
 
901
1355
  alias put2 request_put
902
1356
 
903
- # Sends an HTTP request to the HTTP server.
904
- # Also sends a DATA string if +data+ is given.
1357
+ # <!--
1358
+ # rdoc-file=lib/net/http.rb
1359
+ # - send_request(name, path, data = nil, header = nil)
1360
+ # -->
1361
+ # Sends an HTTP request to the HTTP server. Also sends a DATA string if `data`
1362
+ # is given.
905
1363
  #
906
1364
  # Returns a Net::HTTPResponse object.
907
1365
  #
908
1366
  # This method never raises Net::* exceptions.
909
1367
  #
910
- # response = http.send_request('GET', '/index.html')
911
- # puts response.body
1368
+ # response = http.send_request('GET', '/index.html')
1369
+ # puts response.body
912
1370
  #
913
1371
  def send_request: (String name, String path, ?String? data, ?Hash[String, untyped]? header) -> Net::HTTPResponse
914
1372
 
1373
+ # <!--
1374
+ # rdoc-file=lib/net/http.rb
1375
+ # - request(req, body = nil) { |response| ... }
1376
+ # -->
1377
+ # Sends an HTTPRequest object `req` to the HTTP server.
1378
+ #
1379
+ # If `req` is a Net::HTTP::Post or Net::HTTP::Put request containing data, the
1380
+ # data is also sent. Providing data for a Net::HTTP::Head or Net::HTTP::Get
1381
+ # request results in an ArgumentError.
1382
+ #
1383
+ # Returns an HTTPResponse object.
1384
+ #
1385
+ # When called with a block, passes an HTTPResponse object to the block. The body
1386
+ # of the response will not have been read yet; the block can process it using
1387
+ # HTTPResponse#read_body, if desired.
1388
+ #
1389
+ # This method never raises Net::* exceptions.
1390
+ #
915
1391
  def request: (Net::HTTPRequest req, ?String? body) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
916
-
917
1392
  end
918
1393
 
1394
+ # <!-- rdoc-file=lib/net/http/generic_request.rb -->
1395
+ # HTTPGenericRequest is the parent of the Net::HTTPRequest class. Do not use
1396
+ # this directly; use a subclass of Net::HTTPRequest.
1397
+ #
1398
+ # Mixes in the Net::HTTPHeader module to provide easier access to HTTP headers.
1399
+ #
919
1400
  class HTTPGenericRequest
920
1401
  include Net::HTTPHeader
921
1402
 
922
- def initialize: (String m, boolish reqbody, boolish resbody, (URI::Generic | String) uri_or_path, ?Hash[String, untyped] initheader) -> Net::HTTP
1403
+ # <!--
1404
+ # rdoc-file=lib/net/http/generic_request.rb
1405
+ # - new(m, reqbody, resbody, uri_or_path, initheader = nil)
1406
+ # -->
1407
+ #
1408
+ def initialize: (String m, boolish reqbody, boolish resbody, URI::Generic | String uri_or_path, ?Hash[String, untyped] initheader) -> Net::HTTP
923
1409
 
924
1410
  attr_reader method: String
925
1411
 
@@ -927,27 +1413,71 @@ module Net
927
1413
 
928
1414
  attr_reader uri: URI::Generic
929
1415
 
930
- # Automatically set to false if the user sets the Accept-Encoding header.
931
- # This indicates they wish to handle Content-encoding in responses
932
- # themselves.
1416
+ # <!-- rdoc-file=lib/net/http/generic_request.rb -->
1417
+ # Automatically set to false if the user sets the Accept-Encoding header. This
1418
+ # indicates they wish to handle Content-encoding in responses themselves.
1419
+ #
933
1420
  attr_reader decode_content: bool
934
1421
 
1422
+ # <!--
1423
+ # rdoc-file=lib/net/http/generic_request.rb
1424
+ # - inspect()
1425
+ # -->
1426
+ #
935
1427
  def inspect: () -> String
936
1428
 
937
1429
  def []=: (untyped key, untyped val) -> void
938
1430
 
1431
+ # <!--
1432
+ # rdoc-file=lib/net/http/generic_request.rb
1433
+ # - request_body_permitted?()
1434
+ # -->
1435
+ #
939
1436
  def request_body_permitted?: () -> bool
940
1437
 
1438
+ # <!--
1439
+ # rdoc-file=lib/net/http/generic_request.rb
1440
+ # - response_body_permitted?()
1441
+ # -->
1442
+ #
941
1443
  def response_body_permitted?: () -> bool
942
1444
 
1445
+ # <!--
1446
+ # rdoc-file=lib/net/http/generic_request.rb
1447
+ # - body_exist?()
1448
+ # -->
1449
+ #
943
1450
  def body_exist?: () -> bool
944
1451
 
1452
+ # <!--
1453
+ # rdoc-file=lib/net/http/generic_request.rb
1454
+ # - body=(str)
1455
+ # -->
1456
+ #
945
1457
  attr_accessor body: String?
946
1458
 
1459
+ # <!--
1460
+ # rdoc-file=lib/net/http/generic_request.rb
1461
+ # - body_stream=(input)
1462
+ # -->
1463
+ #
947
1464
  attr_accessor body_stream: untyped
948
1465
  end
949
1466
 
1467
+ # <!-- rdoc-file=lib/net/http/header.rb -->
1468
+ # The HTTPHeader module defines methods for reading and writing HTTP headers.
1469
+ #
1470
+ # It is used as a mixin by other classes, to provide hash-like access to HTTP
1471
+ # header values. Unlike raw hash access, HTTPHeader provides access via
1472
+ # case-insensitive keys. It also provides methods for accessing commonly-used
1473
+ # HTTP header values in more convenient formats.
1474
+ #
950
1475
  module HTTPHeader
1476
+ # <!--
1477
+ # rdoc-file=lib/net/http/header.rb
1478
+ # - initialize_http_header(initheader)
1479
+ # -->
1480
+ #
951
1481
  def initialize_http_header: (Hash[untyped, untyped] initheader) -> void
952
1482
 
953
1483
  def size: () -> Integer
@@ -955,258 +1485,494 @@ module Net
955
1485
  alias length size
956
1486
 
957
1487
  type key = String | Symbol
958
- # Returns the header field corresponding to the case-insensitive key.
959
- # For example, a key of "Content-Type" might return "text/html"
1488
+
1489
+ # <!--
1490
+ # rdoc-file=lib/net/http/header.rb
1491
+ # - [](key)
1492
+ # -->
1493
+ # Returns the header field corresponding to the case-insensitive key. For
1494
+ # example, a key of "Content-Type" might return "text/html"
1495
+ #
960
1496
  def []: (key key) -> (nil | String)
961
1497
 
1498
+ # <!--
1499
+ # rdoc-file=lib/net/http/header.rb
1500
+ # - []=(key, val)
1501
+ # -->
962
1502
  # Sets the header field corresponding to the case-insensitive key.
1503
+ #
963
1504
  def []=: (key key, untyped val) -> void
964
1505
 
965
- # [Ruby 1.8.3]
966
- # Adds a value to a named header field, instead of replacing its value.
967
- # Second argument +val+ must be a String.
968
- # See also #[]=, #[] and #get_fields.
969
- #
970
- # request.add_field 'X-My-Header', 'a'
971
- # p request['X-My-Header'] #=> "a"
972
- # p request.get_fields('X-My-Header') #=> ["a"]
973
- # request.add_field 'X-My-Header', 'b'
974
- # p request['X-My-Header'] #=> "a, b"
975
- # p request.get_fields('X-My-Header') #=> ["a", "b"]
976
- # request.add_field 'X-My-Header', 'c'
977
- # p request['X-My-Header'] #=> "a, b, c"
978
- # p request.get_fields('X-My-Header') #=> ["a", "b", "c"]
1506
+ # <!--
1507
+ # rdoc-file=lib/net/http/header.rb
1508
+ # - add_field(key, val)
1509
+ # -->
1510
+ # Ruby 1.8.3
1511
+ # : Adds a value to a named header field, instead of replacing its value.
1512
+ # Second argument `val` must be a String. See also #[]=, #[] and
1513
+ # #get_fields.
1514
+ #
1515
+ # request.add_field 'X-My-Header', 'a'
1516
+ # p request['X-My-Header'] #=> "a"
1517
+ # p request.get_fields('X-My-Header') #=> ["a"]
1518
+ # request.add_field 'X-My-Header', 'b'
1519
+ # p request['X-My-Header'] #=> "a, b"
1520
+ # p request.get_fields('X-My-Header') #=> ["a", "b"]
1521
+ # request.add_field 'X-My-Header', 'c'
1522
+ # p request['X-My-Header'] #=> "a, b, c"
1523
+ # p request.get_fields('X-My-Header') #=> ["a", "b", "c"]
979
1524
  #
980
1525
  def add_field: (key key, untyped val) -> void
981
1526
 
982
1527
  private
983
1528
 
1529
+ # <!--
1530
+ # rdoc-file=lib/net/http/header.rb
1531
+ # - set_field(key, val)
1532
+ # -->
1533
+ #
984
1534
  def set_field: (key key, untyped val) -> void
985
1535
 
1536
+ # <!--
1537
+ # rdoc-file=lib/net/http/header.rb
1538
+ # - append_field_value(ary, val)
1539
+ # -->
1540
+ #
986
1541
  def append_field_value: (untyped ary, untyped val) -> void
987
1542
 
988
1543
  public
989
1544
 
990
- # [Ruby 1.8.3]
991
- # Returns an array of header field strings corresponding to the
992
- # case-insensitive +key+. This method allows you to get duplicated
993
- # header fields without any processing. See also #[].
994
- #
995
- # p response.get_fields('Set-Cookie')
996
- # #=> ["session=al98axx; expires=Fri, 31-Dec-1999 23:58:23",
997
- # "query=rubyscript; expires=Fri, 31-Dec-1999 23:58:23"]
998
- # p response['Set-Cookie']
999
- # #=> "session=al98axx; expires=Fri, 31-Dec-1999 23:58:23, query=rubyscript; expires=Fri, 31-Dec-1999 23:58:23"
1545
+ # <!--
1546
+ # rdoc-file=lib/net/http/header.rb
1547
+ # - get_fields(key)
1548
+ # -->
1549
+ # Ruby 1.8.3
1550
+ # : Returns an array of header field strings corresponding to the
1551
+ # case-insensitive `key`. This method allows you to get duplicated header
1552
+ # fields without any processing. See also #[].
1553
+ #
1554
+ # p response.get_fields('Set-Cookie')
1555
+ # #=> ["session=al98axx; expires=Fri, 31-Dec-1999 23:58:23",
1556
+ # "query=rubyscript; expires=Fri, 31-Dec-1999 23:58:23"]
1557
+ # p response['Set-Cookie']
1558
+ # #=> "session=al98axx; expires=Fri, 31-Dec-1999 23:58:23, query=rubyscript; expires=Fri, 31-Dec-1999 23:58:23"
1000
1559
  #
1001
1560
  def get_fields: (key key) -> (nil | Array[String])
1002
1561
 
1003
- # Returns the header field corresponding to the case-insensitive key.
1004
- # Returns the default value +args+, or the result of the block, or
1005
- # raises an IndexError if there's no header field named +key+
1006
- # See Hash#fetch
1562
+ # <!--
1563
+ # rdoc-file=lib/net/http/header.rb
1564
+ # - fetch(key, *args) { |key| ... }
1565
+ # -->
1566
+ # Returns the header field corresponding to the case-insensitive key. Returns
1567
+ # the default value `args`, or the result of the block, or raises an IndexError
1568
+ # if there's no header field named `key` See Hash#fetch
1569
+ #
1007
1570
  def fetch: (key key) -> String
1008
1571
  | (key key, untyped) -> untyped
1009
1572
  | (key key) { (String) -> untyped } -> untyped
1010
1573
 
1574
+ # <!--
1575
+ # rdoc-file=lib/net/http/header.rb
1576
+ # - each_header() { |key| ... }
1577
+ # -->
1578
+ # Iterates through the header names and values, passing in the name and value to
1579
+ # the code block supplied.
1580
+ #
1581
+ # Returns an enumerator if no block is given.
1582
+ #
1583
+ # Example:
1584
+ #
1585
+ # response.header.each_header {|key,value| puts "#{key} = #{value}" }
1586
+ #
1011
1587
  def each_header: () { (String, String) -> untyped } -> Hash[String, Array[String]]
1012
- | () -> Enumerator[[String, String], Hash[String, Array[String]]]
1588
+ | () -> Enumerator[[ String, String ], Hash[String, Array[String]]]
1013
1589
 
1590
+ # <!--
1591
+ # rdoc-file=lib/net/http/header.rb
1592
+ # - each()
1593
+ # -->
1594
+ #
1014
1595
  alias each each_header
1015
1596
 
1597
+ # <!--
1598
+ # rdoc-file=lib/net/http/header.rb
1599
+ # - each_name() { |key| ... }
1600
+ # -->
1601
+ # Iterates through the header names in the header, passing each header name to
1602
+ # the code block.
1603
+ #
1604
+ # Returns an enumerator if no block is given.
1605
+ #
1016
1606
  def each_name: () { (String) -> untyped } -> Hash[String, Array[String]]
1017
1607
  | () -> Enumerator[String, Hash[String, Array[String]]]
1018
1608
 
1609
+ # <!--
1610
+ # rdoc-file=lib/net/http/header.rb
1611
+ # - each_key()
1612
+ # -->
1613
+ #
1019
1614
  alias each_key each_name
1020
1615
 
1616
+ # <!--
1617
+ # rdoc-file=lib/net/http/header.rb
1618
+ # - each_capitalized_name() { |key| ... }
1619
+ # -->
1620
+ # Iterates through the header names in the header, passing capitalized header
1621
+ # names to the code block.
1622
+ #
1623
+ # Note that header names are capitalized systematically; capitalization may not
1624
+ # match that used by the remote HTTP server in its response.
1625
+ #
1626
+ # Returns an enumerator if no block is given.
1627
+ #
1021
1628
  def each_capitalized_name: () { (String) -> untyped } -> Hash[String, Array[String]]
1022
1629
  | () -> Enumerator[String, Hash[String, Array[String]]]
1023
1630
 
1631
+ # <!--
1632
+ # rdoc-file=lib/net/http/header.rb
1633
+ # - each_value() { |value| ... }
1634
+ # -->
1635
+ # Iterates through header values, passing each value to the code block.
1636
+ #
1637
+ # Returns an enumerator if no block is given.
1638
+ #
1024
1639
  def each_value: () { (String) -> untyped } -> Hash[String, Array[String]]
1025
1640
  | () -> Enumerator[String, Hash[String, Array[String]]]
1026
1641
 
1642
+ # <!--
1643
+ # rdoc-file=lib/net/http/header.rb
1644
+ # - delete(key)
1645
+ # -->
1027
1646
  # Removes a header field, specified by case-insensitive key.
1647
+ #
1028
1648
  def delete: (key key) -> (Array[String] | nil)
1029
1649
 
1030
- # true if +key+ header exists.
1650
+ # <!--
1651
+ # rdoc-file=lib/net/http/header.rb
1652
+ # - key?(key)
1653
+ # -->
1654
+ # true if `key` header exists.
1655
+ #
1031
1656
  def key?: (key key) -> bool
1032
1657
 
1033
- # Returns a Hash consisting of header names and array of values.
1034
- # e.g.
1658
+ # <!--
1659
+ # rdoc-file=lib/net/http/header.rb
1660
+ # - to_hash()
1661
+ # -->
1662
+ # Returns a Hash consisting of header names and array of values. e.g.
1035
1663
  # {"cache-control" => ["private"],
1036
- # "content-type" => ["text/html"],
1037
- # "date" => ["Wed, 22 Jun 2005 22:11:50 GMT"]}
1664
+ # "content-type" => ["text/html"],
1665
+ # "date" => ["Wed, 22 Jun 2005 22:11:50 GMT"]}
1666
+ #
1038
1667
  def to_hash: () -> Hash[String, Array[String]]
1039
1668
 
1669
+ # <!--
1670
+ # rdoc-file=lib/net/http/header.rb
1671
+ # - each_capitalized() { |capitalize(k), join(', ')| ... }
1672
+ # -->
1040
1673
  # As for #each_header, except the keys are provided in capitalized form.
1041
1674
  #
1042
- # Note that header names are capitalized systematically;
1043
- # capitalization may not match that used by the remote HTTP
1044
- # server in its response.
1675
+ # Note that header names are capitalized systematically; capitalization may not
1676
+ # match that used by the remote HTTP server in its response.
1045
1677
  #
1046
1678
  # Returns an enumerator if no block is given.
1679
+ #
1047
1680
  def each_capitalized: () { (String, String) -> untyped } -> Hash[String, Array[String]]
1048
- | () -> Enumerator[[String, String], Hash[String, Array[String]]]
1681
+ | () -> Enumerator[[ String, String ], Hash[String, Array[String]]]
1049
1682
 
1683
+ # <!--
1684
+ # rdoc-file=lib/net/http/header.rb
1685
+ # - canonical_each()
1686
+ # -->
1687
+ #
1050
1688
  alias canonical_each each_capitalized
1051
1689
 
1052
1690
  private
1053
1691
 
1692
+ # <!--
1693
+ # rdoc-file=lib/net/http/header.rb
1694
+ # - capitalize(name)
1695
+ # -->
1696
+ #
1054
1697
  def capitalize: (key name) -> String
1055
1698
 
1056
1699
  public
1057
1700
 
1058
- # Returns an Array of Range objects which represent the Range:
1059
- # HTTP header field, or +nil+ if there is no such header.
1701
+ # <!--
1702
+ # rdoc-file=lib/net/http/header.rb
1703
+ # - range()
1704
+ # -->
1705
+ # Returns an Array of Range objects which represent the Range: HTTP header
1706
+ # field, or `nil` if there is no such header.
1707
+ #
1060
1708
  def range: () -> (nil | Array[Range[Integer]])
1061
1709
 
1062
- # Sets the HTTP Range: header.
1063
- # Accepts either a Range object as a single argument,
1064
- # or a beginning index and a length from that index.
1065
- # Example:
1710
+ # <!--
1711
+ # rdoc-file=lib/net/http/header.rb
1712
+ # - set_range(r, e = nil)
1713
+ # -->
1714
+ # Sets the HTTP Range: header. Accepts either a Range object as a single
1715
+ # argument, or a beginning index and a length from that index. Example:
1066
1716
  #
1067
- # req.range = (0..1023)
1068
- # req.set_range 0, 1023
1717
+ # req.range = (0..1023)
1718
+ # req.set_range 0, 1023
1069
1719
  #
1070
1720
  def set_range: (Range[Integer] | Numeric r, ?Integer? e) -> Range[Integer]
1071
1721
 
1722
+ # <!--
1723
+ # rdoc-file=lib/net/http/header.rb
1724
+ # - range=(r, e = nil)
1725
+ # -->
1726
+ #
1072
1727
  alias range= set_range
1073
1728
 
1074
- # Returns an Integer object which represents the HTTP Content-Length:
1075
- # header field, or +nil+ if that field was not provided.
1729
+ # <!--
1730
+ # rdoc-file=lib/net/http/header.rb
1731
+ # - content_length()
1732
+ # -->
1733
+ # Returns an Integer object which represents the HTTP Content-Length: header
1734
+ # field, or `nil` if that field was not provided.
1735
+ #
1076
1736
  def content_length: () -> (nil | Integer)
1077
1737
 
1738
+ # <!--
1739
+ # rdoc-file=lib/net/http/header.rb
1740
+ # - content_length=(len)
1741
+ # -->
1742
+ #
1078
1743
  def content_length=: (Integer len) -> void
1079
1744
 
1080
- # Returns "true" if the "transfer-encoding" header is present and
1081
- # set to "chunked". This is an HTTP/1.1 feature, allowing
1082
- # the content to be sent in "chunks" without at the outset
1083
- # stating the entire content length.
1745
+ # <!--
1746
+ # rdoc-file=lib/net/http/header.rb
1747
+ # - chunked?()
1748
+ # -->
1749
+ # Returns "true" if the "transfer-encoding" header is present and set to
1750
+ # "chunked". This is an HTTP/1.1 feature, allowing the content to be sent in
1751
+ # "chunks" without at the outset stating the entire content length.
1752
+ #
1084
1753
  def chunked?: () -> bool
1085
1754
 
1086
- # Returns a Range object which represents the value of the Content-Range:
1087
- # header field.
1088
- # For a partial entity body, this indicates where this fragment
1089
- # fits inside the full entity body, as range of byte offsets.
1755
+ # <!--
1756
+ # rdoc-file=lib/net/http/header.rb
1757
+ # - content_range()
1758
+ # -->
1759
+ # Returns a Range object which represents the value of the Content-Range: header
1760
+ # field. For a partial entity body, this indicates where this fragment fits
1761
+ # inside the full entity body, as range of byte offsets.
1762
+ #
1090
1763
  def content_range: () -> (Range[Integer] | nil)
1091
1764
 
1765
+ # <!--
1766
+ # rdoc-file=lib/net/http/header.rb
1767
+ # - range_length()
1768
+ # -->
1092
1769
  # The length of the range represented in Content-Range: header.
1770
+ #
1093
1771
  def range_length: () -> (nil | Integer)
1094
1772
 
1095
- # Returns a content type string such as "text/html".
1096
- # This method returns nil if Content-Type: header field does not exist.
1773
+ # <!--
1774
+ # rdoc-file=lib/net/http/header.rb
1775
+ # - content_type()
1776
+ # -->
1777
+ # Returns a content type string such as "text/html". This method returns nil if
1778
+ # Content-Type: header field does not exist.
1779
+ #
1097
1780
  def content_type: () -> (nil | String)
1098
1781
 
1099
- # Returns a content type string such as "text".
1100
- # This method returns nil if Content-Type: header field does not exist.
1782
+ # <!--
1783
+ # rdoc-file=lib/net/http/header.rb
1784
+ # - main_type()
1785
+ # -->
1786
+ # Returns a content type string such as "text". This method returns nil if
1787
+ # Content-Type: header field does not exist.
1788
+ #
1101
1789
  def main_type: () -> (nil | String)
1102
1790
 
1103
- # Returns a content type string such as "html".
1104
- # This method returns nil if Content-Type: header field does not exist
1105
- # or sub-type is not given (e.g. "Content-Type: text").
1791
+ # <!--
1792
+ # rdoc-file=lib/net/http/header.rb
1793
+ # - sub_type()
1794
+ # -->
1795
+ # Returns a content type string such as "html". This method returns nil if
1796
+ # Content-Type: header field does not exist or sub-type is not given (e.g.
1797
+ # "Content-Type: text").
1798
+ #
1106
1799
  def sub_type: () -> (nil | String)
1107
1800
 
1108
- # Any parameters specified for the content type, returned as a Hash.
1109
- # For example, a header of Content-Type: text/html; charset=EUC-JP
1110
- # would result in type_params returning {'charset' => 'EUC-JP'}
1801
+ # <!--
1802
+ # rdoc-file=lib/net/http/header.rb
1803
+ # - type_params()
1804
+ # -->
1805
+ # Any parameters specified for the content type, returned as a Hash. For
1806
+ # example, a header of Content-Type: text/html; charset=EUC-JP would result in
1807
+ # type_params returning {'charset' => 'EUC-JP'}
1808
+ #
1111
1809
  def type_params: () -> Hash[untyped, untyped]
1112
1810
 
1113
- # Sets the content type in an HTTP header.
1114
- # The +type+ should be a full HTTP content type, e.g. "text/html".
1115
- # The +params+ are an optional Hash of parameters to add after the
1116
- # content type, e.g. {'charset' => 'iso-8859-1'}
1811
+ # <!--
1812
+ # rdoc-file=lib/net/http/header.rb
1813
+ # - set_content_type(type, params = {})
1814
+ # -->
1815
+ # Sets the content type in an HTTP header. The `type` should be a full HTTP
1816
+ # content type, e.g. "text/html". The `params` are an optional Hash of
1817
+ # parameters to add after the content type, e.g. {'charset' => 'iso-8859-1'}
1818
+ #
1117
1819
  def set_content_type: (key `type`, ?Hash[untyped, untyped] params) -> void
1118
1820
 
1821
+ # <!--
1822
+ # rdoc-file=lib/net/http/header.rb
1823
+ # - content_type=(type, params = {})
1824
+ # -->
1825
+ #
1119
1826
  alias content_type= set_content_type
1120
1827
 
1121
- # Set header fields and a body from HTML form data.
1122
- # +params+ should be an Array of Arrays or
1123
- # a Hash containing HTML form data.
1124
- # Optional argument +sep+ means data record separator.
1828
+ # <!--
1829
+ # rdoc-file=lib/net/http/header.rb
1830
+ # - set_form_data(params, sep = '&')
1831
+ # -->
1832
+ # Set header fields and a body from HTML form data. `params` should be an Array
1833
+ # of Arrays or a Hash containing HTML form data. Optional argument `sep` means
1834
+ # data record separator.
1125
1835
  #
1126
1836
  # Values are URL encoded as necessary and the content-type is set to
1127
1837
  # application/x-www-form-urlencoded
1128
1838
  #
1129
1839
  # Example:
1130
- # http.form_data = {"q" => "ruby", "lang" => "en"}
1131
- # http.form_data = {"q" => ["ruby", "perl"], "lang" => "en"}
1132
- # http.set_form_data({"q" => "ruby", "lang" => "en"}, ';')
1840
+ # http.form_data = {"q" => "ruby", "lang" => "en"}
1841
+ # http.form_data = {"q" => ["ruby", "perl"], "lang" => "en"}
1842
+ # http.set_form_data({"q" => "ruby", "lang" => "en"}, ';')
1133
1843
  #
1134
1844
  def set_form_data: (Hash[untyped, untyped] params, ?String sep) -> void
1135
1845
 
1846
+ # <!--
1847
+ # rdoc-file=lib/net/http/header.rb
1848
+ # - form_data=(params, sep = '&')
1849
+ # -->
1850
+ #
1136
1851
  alias form_data= set_form_data
1137
1852
 
1853
+ # <!--
1854
+ # rdoc-file=lib/net/http/header.rb
1855
+ # - set_form(params, enctype='application/x-www-form-urlencoded', formopt={})
1856
+ # -->
1138
1857
  # Set an HTML form data set.
1139
- # +params+ :: The form data to set, which should be an enumerable.
1140
- # See below for more details.
1141
- # +enctype+ :: The content type to use to encode the form submission,
1142
- # which should be application/x-www-form-urlencoded or
1143
- # multipart/form-data.
1144
- # +formopt+ :: An options hash, supporting the following options:
1145
- # :boundary :: The boundary of the multipart message. If
1146
- # not given, a random boundary will be used.
1147
- # :charset :: The charset of the form submission. All
1148
- # field names and values of non-file fields
1149
- # should be encoded with this charset.
1150
- #
1151
- # Each item of params should respond to +each+ and yield 2-3 arguments,
1152
- # or an array of 2-3 elements. The arguments yielded should be:
1153
- # * The name of the field.
1154
- # * The value of the field, it should be a String or a File or IO-like.
1155
- # * An options hash, supporting the following options, only
1156
- # used for file uploads:
1157
- # :filename :: The name of the file to use.
1158
- # :content_type :: The content type of the uploaded file.
1159
- #
1160
- # Each item is a file field or a normal field.
1161
- # If +value+ is a File object or the +opt+ hash has a :filename key,
1162
- # the item is treated as a file field.
1163
- #
1164
- # If Transfer-Encoding is set as chunked, this sends the request using
1165
- # chunked encoding. Because chunked encoding is HTTP/1.1 feature,
1166
- # you should confirm that the server supports HTTP/1.1 before using
1167
- # chunked encoding.
1858
+ # `params`
1859
+ # : The form data to set, which should be an enumerable. See below for more
1860
+ # details.
1861
+ # `enctype`
1862
+ # : The content type to use to encode the form submission, which should be
1863
+ # application/x-www-form-urlencoded or multipart/form-data.
1864
+ # `formopt`
1865
+ # : An options hash, supporting the following options:
1866
+ # :boundary
1867
+ # : The boundary of the multipart message. If not given, a random boundary
1868
+ # will be used.
1869
+ # :charset
1870
+ # : The charset of the form submission. All field names and values of
1871
+ # non-file fields should be encoded with this charset.
1872
+ #
1873
+ #
1874
+ #
1875
+ # Each item of params should respond to `each` and yield 2-3 arguments, or an
1876
+ # array of 2-3 elements. The arguments yielded should be:
1877
+ # * The name of the field.
1878
+ # * The value of the field, it should be a String or a File or IO-like.
1879
+ # * An options hash, supporting the following options, only
1880
+ # used for file uploads:
1881
+ # :filename :: The name of the file to use.
1882
+ # :content_type :: The content type of the uploaded file.
1883
+ #
1884
+ # Each item is a file field or a normal field. If `value` is a File object or
1885
+ # the `opt` hash has a :filename key, the item is treated as a file field.
1886
+ #
1887
+ # If Transfer-Encoding is set as chunked, this sends the request using chunked
1888
+ # encoding. Because chunked encoding is HTTP/1.1 feature, you should confirm
1889
+ # that the server supports HTTP/1.1 before using chunked encoding.
1168
1890
  #
1169
1891
  # Example:
1170
- # req.set_form([["q", "ruby"], ["lang", "en"]])
1892
+ # req.set_form([["q", "ruby"], ["lang", "en"]])
1171
1893
  #
1172
- # req.set_form({"f"=>File.open('/path/to/filename')},
1173
- # "multipart/form-data",
1174
- # charset: "UTF-8",
1175
- # )
1894
+ # req.set_form({"f"=>File.open('/path/to/filename')},
1895
+ # "multipart/form-data",
1896
+ # charset: "UTF-8",
1897
+ # )
1176
1898
  #
1177
- # req.set_form([["f",
1178
- # File.open('/path/to/filename.bar'),
1179
- # {filename: "other-filename.foo"}
1180
- # ]],
1181
- # "multipart/form-data",
1182
- # )
1899
+ # req.set_form([["f",
1900
+ # File.open('/path/to/filename.bar'),
1901
+ # {filename: "other-filename.foo"}
1902
+ # ]],
1903
+ # "multipart/form-data",
1904
+ # )
1183
1905
  #
1184
1906
  # See also RFC 2388, RFC 2616, HTML 4.01, and HTML5
1185
1907
  #
1186
1908
  def set_form: (Hash[untyped, untyped] params, ?String enctype, ?Hash[untyped, untyped] formopt) -> void
1187
1909
 
1910
+ # <!--
1911
+ # rdoc-file=lib/net/http/header.rb
1912
+ # - basic_auth(account, password)
1913
+ # -->
1188
1914
  # Set the Authorization: header for "Basic" authorization.
1915
+ #
1189
1916
  def basic_auth: (String account, String password) -> void
1190
1917
 
1918
+ # <!--
1919
+ # rdoc-file=lib/net/http/header.rb
1920
+ # - proxy_basic_auth(account, password)
1921
+ # -->
1191
1922
  # Set Proxy-Authorization: header for "Basic" authorization.
1923
+ #
1192
1924
  def proxy_basic_auth: (String account, String password) -> void
1193
1925
 
1194
1926
  private
1195
1927
 
1928
+ # <!--
1929
+ # rdoc-file=lib/net/http/header.rb
1930
+ # - basic_encode(account, password)
1931
+ # -->
1932
+ #
1196
1933
  def basic_encode: (String account, String password) -> String
1197
1934
 
1198
1935
  public
1199
1936
 
1937
+ # <!--
1938
+ # rdoc-file=lib/net/http/header.rb
1939
+ # - connection_close?()
1940
+ # -->
1941
+ #
1200
1942
  def connection_close?: () -> bool
1201
1943
 
1944
+ # <!--
1945
+ # rdoc-file=lib/net/http/header.rb
1946
+ # - connection_keep_alive?()
1947
+ # -->
1948
+ #
1202
1949
  def connection_keep_alive?: () -> bool
1203
1950
  end
1204
1951
 
1952
+ # <!-- rdoc-file=lib/net/http/request.rb -->
1953
+ # HTTP request class. This class wraps together the request header and the
1954
+ # request path. You cannot use this class directly. Instead, you should use one
1955
+ # of its subclasses: Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Head.
1956
+ #
1205
1957
  class HTTPRequest < HTTPGenericRequest
1958
+ # <!--
1959
+ # rdoc-file=lib/net/http/request.rb
1960
+ # - new(path, initheader = nil)
1961
+ # -->
1962
+ # Creates an HTTP request object for `path`.
1963
+ #
1964
+ # `initheader` are the default headers to use. Net::HTTP adds Accept-Encoding
1965
+ # to enable compression of the response body unless Accept-Encoding or Range are
1966
+ # supplied in `initheader`.
1967
+ #
1206
1968
  def initialize: (String path, ?Hash[String, untyped] initheader) -> void
1207
1969
  | (URI::Generic uri, ?Hash[String, untyped] initheader) -> void
1208
1970
  end
1209
1971
 
1972
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1973
+ # See Net::HTTPGenericRequest for attributes and methods. See Net::HTTP for
1974
+ # usage examples.
1975
+ #
1210
1976
  class HTTP::Get < HTTPRequest
1211
1977
  METHOD: String
1212
1978
 
@@ -1215,8 +1981,10 @@ module Net
1215
1981
  RESPONSE_HAS_BODY: bool
1216
1982
  end
1217
1983
 
1218
- # See Net::HTTPGenericRequest for attributes and methods.
1219
- # See Net::HTTP for usage examples.
1984
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1985
+ # See Net::HTTPGenericRequest for attributes and methods. See Net::HTTP for
1986
+ # usage examples.
1987
+ #
1220
1988
  class HTTP::Head < HTTPRequest
1221
1989
  METHOD: String
1222
1990
 
@@ -1225,8 +1993,10 @@ module Net
1225
1993
  RESPONSE_HAS_BODY: bool
1226
1994
  end
1227
1995
 
1228
- # See Net::HTTPGenericRequest for attributes and methods.
1229
- # See Net::HTTP for usage examples.
1996
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1997
+ # See Net::HTTPGenericRequest for attributes and methods. See Net::HTTP for
1998
+ # usage examples.
1999
+ #
1230
2000
  class HTTP::Post < HTTPRequest
1231
2001
  METHOD: String
1232
2002
 
@@ -1235,8 +2005,10 @@ module Net
1235
2005
  RESPONSE_HAS_BODY: bool
1236
2006
  end
1237
2007
 
1238
- # See Net::HTTPGenericRequest for attributes and methods.
1239
- # See Net::HTTP for usage examples.
2008
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
2009
+ # See Net::HTTPGenericRequest for attributes and methods. See Net::HTTP for
2010
+ # usage examples.
2011
+ #
1240
2012
  class HTTP::Put < HTTPRequest
1241
2013
  METHOD: String
1242
2014
 
@@ -1245,8 +2017,10 @@ module Net
1245
2017
  RESPONSE_HAS_BODY: bool
1246
2018
  end
1247
2019
 
1248
- # See Net::HTTPGenericRequest for attributes and methods.
1249
- # See Net::HTTP for usage examples.
2020
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
2021
+ # See Net::HTTPGenericRequest for attributes and methods. See Net::HTTP for
2022
+ # usage examples.
2023
+ #
1250
2024
  class HTTP::Delete < HTTPRequest
1251
2025
  METHOD: String
1252
2026
 
@@ -1255,7 +2029,9 @@ module Net
1255
2029
  RESPONSE_HAS_BODY: bool
1256
2030
  end
1257
2031
 
2032
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1258
2033
  # See Net::HTTPGenericRequest for attributes and methods.
2034
+ #
1259
2035
  class HTTP::Options < HTTPRequest
1260
2036
  METHOD: String
1261
2037
 
@@ -1264,7 +2040,9 @@ module Net
1264
2040
  RESPONSE_HAS_BODY: bool
1265
2041
  end
1266
2042
 
2043
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1267
2044
  # See Net::HTTPGenericRequest for attributes and methods.
2045
+ #
1268
2046
  class HTTP::Trace < HTTPRequest
1269
2047
  METHOD: String
1270
2048
 
@@ -1273,7 +2051,9 @@ module Net
1273
2051
  RESPONSE_HAS_BODY: bool
1274
2052
  end
1275
2053
 
2054
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1276
2055
  # See Net::HTTPGenericRequest for attributes and methods.
2056
+ #
1277
2057
  class HTTP::Patch < HTTPRequest
1278
2058
  METHOD: String
1279
2059
 
@@ -1282,7 +2062,9 @@ module Net
1282
2062
  RESPONSE_HAS_BODY: bool
1283
2063
  end
1284
2064
 
2065
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1285
2066
  # See Net::HTTPGenericRequest for attributes and methods.
2067
+ #
1286
2068
  class HTTP::Propfind < HTTPRequest
1287
2069
  METHOD: String
1288
2070
 
@@ -1291,7 +2073,9 @@ module Net
1291
2073
  RESPONSE_HAS_BODY: bool
1292
2074
  end
1293
2075
 
2076
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1294
2077
  # See Net::HTTPGenericRequest for attributes and methods.
2078
+ #
1295
2079
  class HTTP::Proppatch < HTTPRequest
1296
2080
  METHOD: String
1297
2081
 
@@ -1300,7 +2084,9 @@ module Net
1300
2084
  RESPONSE_HAS_BODY: bool
1301
2085
  end
1302
2086
 
2087
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1303
2088
  # See Net::HTTPGenericRequest for attributes and methods.
2089
+ #
1304
2090
  class HTTP::Mkcol < HTTPRequest
1305
2091
  METHOD: String
1306
2092
 
@@ -1309,7 +2095,9 @@ module Net
1309
2095
  RESPONSE_HAS_BODY: bool
1310
2096
  end
1311
2097
 
2098
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1312
2099
  # See Net::HTTPGenericRequest for attributes and methods.
2100
+ #
1313
2101
  class HTTP::Copy < HTTPRequest
1314
2102
  METHOD: String
1315
2103
 
@@ -1318,7 +2106,9 @@ module Net
1318
2106
  RESPONSE_HAS_BODY: bool
1319
2107
  end
1320
2108
 
2109
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1321
2110
  # See Net::HTTPGenericRequest for attributes and methods.
2111
+ #
1322
2112
  class HTTP::Move < HTTPRequest
1323
2113
  METHOD: String
1324
2114
 
@@ -1327,7 +2117,9 @@ module Net
1327
2117
  RESPONSE_HAS_BODY: bool
1328
2118
  end
1329
2119
 
2120
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1330
2121
  # See Net::HTTPGenericRequest for attributes and methods.
2122
+ #
1331
2123
  class HTTP::Lock < HTTPRequest
1332
2124
  METHOD: String
1333
2125
 
@@ -1336,7 +2128,9 @@ module Net
1336
2128
  RESPONSE_HAS_BODY: bool
1337
2129
  end
1338
2130
 
2131
+ # <!-- rdoc-file=lib/net/http/requests.rb -->
1339
2132
  # See Net::HTTPGenericRequest for attributes and methods.
2133
+ #
1340
2134
  class HTTP::Unlock < HTTPRequest
1341
2135
  METHOD: String
1342
2136
 
@@ -1345,35 +2139,75 @@ module Net
1345
2139
  RESPONSE_HAS_BODY: bool
1346
2140
  end
1347
2141
 
2142
+ # <!-- rdoc-file=lib/net/http/response.rb -->
2143
+ # HTTP response class.
2144
+ #
2145
+ # This class wraps together the response header and the response body (the
2146
+ # entity requested).
2147
+ #
2148
+ # It mixes in the HTTPHeader module, which provides access to response header
2149
+ # values both via hash-like methods and via individual readers.
2150
+ #
2151
+ # Note that each possible HTTP response code defines its own HTTPResponse
2152
+ # subclass. All classes are defined under the Net module. Indentation indicates
2153
+ # inheritance. For a list of the classes see Net::HTTP.
2154
+ #
2155
+ # Correspondence `HTTP code => class` is stored in CODE_TO_OBJ constant:
2156
+ #
2157
+ # Net::HTTPResponse::CODE_TO_OBJ['404'] #=> Net::HTTPNotFound
2158
+ #
1348
2159
  class HTTPResponse
2160
+ # <!--
2161
+ # rdoc-file=lib/net/http/response.rb
2162
+ # - body_permitted?()
2163
+ # -->
1349
2164
  # true if the response has a body.
2165
+ #
1350
2166
  def self.body_permitted?: () -> bool
1351
2167
 
1352
2168
  public
1353
2169
 
1354
2170
  include Net::HTTPHeader
1355
2171
 
2172
+ # <!-- rdoc-file=lib/net/http/response.rb -->
1356
2173
  # The HTTP version supported by the server.
2174
+ #
1357
2175
  attr_reader http_version: String
1358
2176
 
1359
- # The HTTP result code string. For example, '302'. You can also
1360
- # determine the response type by examining which response subclass
1361
- # the response object is an instance of.
2177
+ # <!-- rdoc-file=lib/net/http/response.rb -->
2178
+ # The HTTP result code string. For example, '302'. You can also determine the
2179
+ # response type by examining which response subclass the response object is an
2180
+ # instance of.
2181
+ #
1362
2182
  attr_reader code: String
1363
2183
 
2184
+ # <!-- rdoc-file=lib/net/http/response.rb -->
1364
2185
  # The HTTP result message sent by the server. For example, 'Not Found'.
2186
+ #
1365
2187
  attr_reader message: String
1366
2188
 
2189
+ # <!-- rdoc-file=lib/net/http/response.rb -->
2190
+ # The HTTP result message sent by the server. For example, 'Not Found'.
2191
+ #
1367
2192
  alias msg message
1368
2193
 
1369
- # The URI used to fetch this response. The response URI is only available
1370
- # if a URI was used to create the request.
1371
- attr_reader uri: (URI::Generic | nil)
2194
+ # <!-- rdoc-file=lib/net/http/response.rb -->
2195
+ # The URI used to fetch this response. The response URI is only available if a
2196
+ # URI was used to create the request.
2197
+ #
2198
+ attr_reader uri: URI::Generic | nil
1372
2199
 
1373
- # Set to true automatically when the request did not contain an
1374
- # Accept-Encoding header from the user.
2200
+ # <!-- rdoc-file=lib/net/http/response.rb -->
2201
+ # Set to true automatically when the request did not contain an Accept-Encoding
2202
+ # header from the user.
2203
+ #
1375
2204
  attr_accessor decode_content: bool
1376
2205
 
2206
+ # <!--
2207
+ # rdoc-file=lib/net/http/response.rb
2208
+ # - inspect()
2209
+ # -->
2210
+ #
1377
2211
  def inspect: () -> String
1378
2212
 
1379
2213
  def code_type: () -> untyped
@@ -1382,7 +2216,12 @@ module Net
1382
2216
 
1383
2217
  def error_type: () -> (Net::HTTPError | Net::HTTPServerException | Net::HTTPRetriableError | Net::HTTPFatalError)
1384
2218
 
2219
+ # <!--
2220
+ # rdoc-file=lib/net/http/response.rb
2221
+ # - value()
2222
+ # -->
1385
2223
  # Raises an HTTP error if the response is not 2xx (success).
2224
+ #
1386
2225
  def value: () -> (nil | untyped)
1387
2226
 
1388
2227
  def uri=: (URI::Generic uri) -> void
@@ -1391,61 +2230,82 @@ module Net
1391
2230
  def <<: (String) -> void
1392
2231
  end
1393
2232
 
2233
+ # <!--
2234
+ # rdoc-file=lib/net/http/response.rb
2235
+ # - read_body(dest = nil, &block)
2236
+ # -->
1394
2237
  # Gets the entity body returned by the remote HTTP server.
1395
2238
  #
1396
- # If a block is given, the body is passed to the block, and
1397
- # the body is provided in fragments, as it is read in from the socket.
2239
+ # If a block is given, the body is passed to the block, and the body is provided
2240
+ # in fragments, as it is read in from the socket.
1398
2241
  #
1399
- # If +dest+ argument is given, response is read into that variable,
1400
- # with <code>dest#<<</code> method (it could be String or IO, or any
1401
- # other object responding to <code><<</code>).
2242
+ # If `dest` argument is given, response is read into that variable, with
2243
+ # `dest#<<` method (it could be String or IO, or any other object responding to
2244
+ # `<<`).
1402
2245
  #
1403
- # Calling this method a second or subsequent time for the same
1404
- # HTTPResponse object will return the value already read.
2246
+ # Calling this method a second or subsequent time for the same HTTPResponse
2247
+ # object will return the value already read.
1405
2248
  #
1406
- # http.request_get('/index.html') {|res|
1407
- # puts res.read_body
1408
- # }
2249
+ # http.request_get('/index.html') {|res|
2250
+ # puts res.read_body
2251
+ # }
1409
2252
  #
1410
- # http.request_get('/index.html') {|res|
1411
- # p res.read_body.object_id # 538149362
1412
- # p res.read_body.object_id # 538149362
1413
- # }
2253
+ # http.request_get('/index.html') {|res|
2254
+ # p res.read_body.object_id # 538149362
2255
+ # p res.read_body.object_id # 538149362
2256
+ # }
1414
2257
  #
1415
- # # using iterator
1416
- # http.request_get('/index.html') {|res|
1417
- # res.read_body do |segment|
1418
- # print segment
1419
- # end
1420
- # }
2258
+ # # using iterator
2259
+ # http.request_get('/index.html') {|res|
2260
+ # res.read_body do |segment|
2261
+ # print segment
2262
+ # end
2263
+ # }
1421
2264
  #
1422
2265
  def read_body: () -> String
1423
2266
  | (_Dest dest) -> String
1424
2267
  | () { (String) -> void } -> String
1425
2268
 
2269
+ # <!--
2270
+ # rdoc-file=lib/net/http/response.rb
2271
+ # - body()
2272
+ # -->
1426
2273
  # Returns the full entity body.
1427
2274
  #
1428
- # Calling this method a second or subsequent time will return the
1429
- # string already read.
2275
+ # Calling this method a second or subsequent time will return the string already
2276
+ # read.
1430
2277
  #
1431
- # http.request_get('/index.html') {|res|
1432
- # puts res.body
1433
- # }
2278
+ # http.request_get('/index.html') {|res|
2279
+ # puts res.body
2280
+ # }
1434
2281
  #
1435
- # http.request_get('/index.html') {|res|
1436
- # p res.body.object_id # 538149362
1437
- # p res.body.object_id # 538149362
1438
- # }
2282
+ # http.request_get('/index.html') {|res|
2283
+ # p res.body.object_id # 538149362
2284
+ # p res.body.object_id # 538149362
2285
+ # }
1439
2286
  #
1440
2287
  def body: () -> String
1441
2288
 
1442
- # Because it may be necessary to modify the body, Eg, decompression
1443
- # this method facilitates that.
2289
+ # <!--
2290
+ # rdoc-file=lib/net/http/response.rb
2291
+ # - body=(value)
2292
+ # -->
2293
+ # Because it may be necessary to modify the body, Eg, decompression this method
2294
+ # facilitates that.
2295
+ #
1444
2296
  def body=: (untyped value) -> void
1445
2297
 
2298
+ # <!--
2299
+ # rdoc-file=lib/net/http/response.rb
2300
+ # - entity()
2301
+ # -->
2302
+ #
1446
2303
  alias entity body
1447
2304
  end
1448
2305
 
2306
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
2307
+ # https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
2308
+ #
1449
2309
  class HTTPUnknownResponse < HTTPResponse
1450
2310
  HAS_BODY: bool
1451
2311
 
@@ -1453,362 +2313,310 @@ module Net
1453
2313
  end
1454
2314
 
1455
2315
  class HTTPInformation < HTTPResponse
1456
- # 1xx
1457
2316
  HAS_BODY: bool
1458
2317
 
1459
2318
  EXCEPTION_TYPE: Net::HTTPError
1460
2319
  end
1461
2320
 
1462
2321
  class HTTPSuccess < HTTPResponse
1463
- # 2xx
1464
2322
  HAS_BODY: bool
1465
2323
 
1466
2324
  EXCEPTION_TYPE: Net::HTTPError
1467
2325
  end
1468
2326
 
1469
2327
  class HTTPRedirection < HTTPResponse
1470
- # 3xx
1471
2328
  HAS_BODY: bool
1472
2329
 
1473
- EXCEPTION_TYPE: Net::HTTPRetriableError
2330
+ EXCEPTION_TYPE: Net::HTTPRetriableError
1474
2331
  end
1475
2332
 
1476
2333
  class HTTPClientError < HTTPResponse
1477
- # 4xx
1478
2334
  HAS_BODY: bool
1479
2335
 
1480
- # EXCEPTION_TYPE: Net::HTTPClientException -> Change after introduction of class/module alias
1481
2336
  EXCEPTION_TYPE: untyped
1482
2337
  end
1483
2338
 
1484
2339
  class HTTPServerError < HTTPResponse
1485
- # 5xx
1486
2340
  HAS_BODY: bool
1487
2341
 
1488
2342
  EXCEPTION_TYPE: Net::HTTPFatalError
1489
2343
  end
1490
2344
 
1491
2345
  class HTTPContinue < HTTPInformation
1492
- # 100
1493
2346
  HAS_BODY: bool
1494
2347
  end
1495
2348
 
1496
2349
  class HTTPSwitchProtocol < HTTPInformation
1497
- # 101
1498
2350
  HAS_BODY: bool
1499
2351
  end
1500
2352
 
1501
2353
  class HTTPProcessing < HTTPInformation
1502
- # 102
1503
2354
  HAS_BODY: bool
1504
2355
  end
1505
2356
 
1506
2357
  class HTTPEarlyHints < HTTPInformation
1507
- # 103 - RFC 8297
1508
2358
  HAS_BODY: bool
1509
2359
  end
1510
2360
 
1511
2361
  class HTTPOK < HTTPSuccess
1512
- # 200
1513
2362
  HAS_BODY: bool
1514
2363
  end
1515
2364
 
1516
2365
  class HTTPCreated < HTTPSuccess
1517
- # 201
1518
2366
  HAS_BODY: bool
1519
2367
  end
1520
2368
 
1521
2369
  class HTTPAccepted < HTTPSuccess
1522
- # 202
1523
2370
  HAS_BODY: bool
1524
2371
  end
1525
2372
 
1526
2373
  class HTTPNonAuthoritativeInformation < HTTPSuccess
1527
- # 203
1528
2374
  HAS_BODY: bool
1529
2375
  end
1530
2376
 
1531
2377
  class HTTPNoContent < HTTPSuccess
1532
- # 204
1533
2378
  HAS_BODY: bool
1534
2379
  end
1535
2380
 
1536
2381
  class HTTPResetContent < HTTPSuccess
1537
- # 205
1538
2382
  HAS_BODY: bool
1539
2383
  end
1540
2384
 
1541
2385
  class HTTPPartialContent < HTTPSuccess
1542
- # 206
1543
2386
  HAS_BODY: bool
1544
2387
  end
1545
2388
 
1546
2389
  class HTTPMultiStatus < HTTPSuccess
1547
- # 207 - RFC 4918
1548
2390
  HAS_BODY: bool
1549
2391
  end
1550
2392
 
1551
2393
  class HTTPAlreadyReported < HTTPSuccess
1552
- # 208 - RFC 5842
1553
2394
  HAS_BODY: bool
1554
2395
  end
1555
2396
 
1556
2397
  class HTTPIMUsed < HTTPSuccess
1557
- # 226 - RFC 3229
1558
2398
  HAS_BODY: bool
1559
2399
  end
1560
2400
 
1561
2401
  class HTTPMultipleChoices < HTTPRedirection
1562
- # 300
1563
2402
  HAS_BODY: bool
1564
2403
  end
1565
2404
 
1566
2405
  HTTPMultipleChoice: HTTPMultipleChoices
1567
2406
 
1568
2407
  class HTTPMovedPermanently < HTTPRedirection
1569
- # 301
1570
2408
  HAS_BODY: bool
1571
2409
  end
1572
2410
 
1573
2411
  class HTTPFound < HTTPRedirection
1574
- # 302
1575
2412
  HAS_BODY: bool
1576
2413
  end
1577
2414
 
1578
- # HTTPMovedTemporarily: HTTPFound
1579
-
1580
2415
  class HTTPSeeOther < HTTPRedirection
1581
- # 303
1582
2416
  HAS_BODY: bool
1583
2417
  end
1584
2418
 
1585
2419
  class HTTPNotModified < HTTPRedirection
1586
- # 304
1587
2420
  HAS_BODY: bool
1588
2421
  end
1589
2422
 
1590
2423
  class HTTPUseProxy < HTTPRedirection
1591
- # 305
1592
2424
  HAS_BODY: bool
1593
2425
  end
1594
2426
 
2427
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
2428
+ # 306 Switch Proxy - no longer unused
2429
+ #
1595
2430
  class HTTPTemporaryRedirect < HTTPRedirection
1596
- # 306 Switch Proxy - no longer unused
1597
- # 307
1598
2431
  HAS_BODY: bool
1599
2432
  end
1600
2433
 
1601
2434
  class HTTPPermanentRedirect < HTTPRedirection
1602
- # 308
1603
2435
  HAS_BODY: bool
1604
2436
  end
1605
2437
 
1606
2438
  class HTTPBadRequest < HTTPClientError
1607
- # 400
1608
2439
  HAS_BODY: bool
1609
2440
  end
1610
2441
 
1611
2442
  class HTTPUnauthorized < HTTPClientError
1612
- # 401
1613
2443
  HAS_BODY: bool
1614
2444
  end
1615
2445
 
1616
2446
  class HTTPPaymentRequired < HTTPClientError
1617
- # 402
1618
2447
  HAS_BODY: bool
1619
2448
  end
1620
2449
 
1621
2450
  class HTTPForbidden < HTTPClientError
1622
- # 403
1623
2451
  HAS_BODY: bool
1624
2452
  end
1625
2453
 
1626
2454
  class HTTPNotFound < HTTPClientError
1627
- # 404
1628
2455
  HAS_BODY: bool
1629
2456
  end
1630
2457
 
1631
2458
  class HTTPMethodNotAllowed < HTTPClientError
1632
- # 405
1633
2459
  HAS_BODY: bool
1634
2460
  end
1635
2461
 
1636
2462
  class HTTPNotAcceptable < HTTPClientError
1637
- # 406
1638
2463
  HAS_BODY: bool
1639
2464
  end
1640
2465
 
1641
2466
  class HTTPProxyAuthenticationRequired < HTTPClientError
1642
- # 407
1643
2467
  HAS_BODY: bool
1644
2468
  end
1645
2469
 
1646
2470
  class HTTPRequestTimeout < HTTPClientError
1647
- # 408
1648
2471
  HAS_BODY: bool
1649
2472
  end
1650
2473
 
1651
- # HTTPRequestTimeOut: HTTPRequestTimeout
1652
-
1653
2474
  class HTTPConflict < HTTPClientError
1654
- # 409
1655
2475
  HAS_BODY: bool
1656
2476
  end
1657
2477
 
1658
2478
  class HTTPGone < HTTPClientError
1659
- # 410
1660
2479
  HAS_BODY: bool
1661
2480
  end
1662
2481
 
1663
2482
  class HTTPLengthRequired < HTTPClientError
1664
- # 411
1665
2483
  HAS_BODY: bool
1666
2484
  end
1667
2485
 
1668
2486
  class HTTPPreconditionFailed < HTTPClientError
1669
- # 412
1670
2487
  HAS_BODY: bool
1671
2488
  end
1672
2489
 
1673
2490
  class HTTPPayloadTooLarge < HTTPClientError
1674
- # 413
1675
2491
  HAS_BODY: bool
1676
2492
  end
1677
2493
 
1678
- # HTTPRequestEntityTooLarge: untyped
1679
-
1680
2494
  class HTTPURITooLong < HTTPClientError
1681
- # 414
1682
2495
  HAS_BODY: bool
1683
2496
  end
1684
2497
 
1685
- # HTTPRequestURITooLong: untyped
1686
-
1687
- # HTTPRequestURITooLarge: untyped
1688
-
1689
2498
  class HTTPUnsupportedMediaType < HTTPClientError
1690
- # 415
1691
2499
  HAS_BODY: bool
1692
2500
  end
1693
2501
 
1694
2502
  class HTTPRangeNotSatisfiable < HTTPClientError
1695
- # 416
1696
2503
  HAS_BODY: bool
1697
2504
  end
1698
2505
 
1699
- # HTTPRequestedRangeNotSatisfiable: untyped
1700
-
1701
2506
  class HTTPExpectationFailed < HTTPClientError
1702
- # 417
1703
2507
  HAS_BODY: bool
1704
2508
  end
1705
2509
 
2510
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
2511
+ # 418 I'm a teapot - RFC 2324; a joke RFC 420 Enhance Your Calm - Twitter
2512
+ #
1706
2513
  class HTTPMisdirectedRequest < HTTPClientError
1707
- # 418 I'm a teapot - RFC 2324; a joke RFC
1708
- # 420 Enhance Your Calm - Twitter
1709
- # 421 - RFC 7540
1710
2514
  HAS_BODY: bool
1711
2515
  end
1712
2516
 
1713
2517
  class HTTPUnprocessableEntity < HTTPClientError
1714
- # 422 - RFC 4918
1715
2518
  HAS_BODY: bool
1716
2519
  end
1717
2520
 
1718
2521
  class HTTPLocked < HTTPClientError
1719
- # 423 - RFC 4918
1720
2522
  HAS_BODY: bool
1721
2523
  end
1722
2524
 
1723
2525
  class HTTPFailedDependency < HTTPClientError
1724
- # 424 - RFC 4918
1725
2526
  HAS_BODY: bool
1726
2527
  end
1727
2528
 
2529
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
2530
+ # 425 Unordered Collection - existed only in draft
2531
+ #
1728
2532
  class HTTPUpgradeRequired < HTTPClientError
1729
- # 425 Unordered Collection - existed only in draft
1730
- # 426 - RFC 2817
1731
2533
  HAS_BODY: bool
1732
2534
  end
1733
2535
 
1734
2536
  class HTTPPreconditionRequired < HTTPClientError
1735
- # 428 - RFC 6585
1736
2537
  HAS_BODY: bool
1737
2538
  end
1738
2539
 
1739
2540
  class HTTPTooManyRequests < HTTPClientError
1740
- # 429 - RFC 6585
1741
2541
  HAS_BODY: bool
1742
2542
  end
1743
2543
 
1744
2544
  class HTTPRequestHeaderFieldsTooLarge < HTTPClientError
1745
- # 431 - RFC 6585
1746
2545
  HAS_BODY: bool
1747
2546
  end
1748
2547
 
1749
2548
  class HTTPUnavailableForLegalReasons < HTTPClientError
1750
- # 451 - RFC 7725
1751
2549
  HAS_BODY: bool
1752
2550
  end
1753
2551
 
2552
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
2553
+ # 444 No Response - Nginx 449 Retry With - Microsoft 450 Blocked by Windows
2554
+ # Parental Controls - Microsoft 499 Client Closed Request - Nginx
2555
+ #
1754
2556
  class HTTPInternalServerError < HTTPServerError
1755
- # 500
1756
2557
  HAS_BODY: bool
1757
2558
  end
1758
2559
 
1759
2560
  class HTTPNotImplemented < HTTPServerError
1760
- # 501
1761
2561
  HAS_BODY: bool
1762
2562
  end
1763
2563
 
1764
2564
  class HTTPBadGateway < HTTPServerError
1765
- # 502
1766
2565
  HAS_BODY: bool
1767
2566
  end
1768
2567
 
1769
2568
  class HTTPServiceUnavailable < HTTPServerError
1770
- # 503
1771
2569
  HAS_BODY: bool
1772
2570
  end
1773
2571
 
1774
2572
  class HTTPGatewayTimeout < HTTPServerError
1775
- # 504
1776
2573
  HAS_BODY: bool
1777
2574
  end
1778
2575
 
1779
- # HTTPGatewayTimeOut: untyped
1780
-
1781
2576
  class HTTPVersionNotSupported < HTTPServerError
1782
- # 505
1783
2577
  HAS_BODY: bool
1784
2578
  end
1785
2579
 
1786
2580
  class HTTPVariantAlsoNegotiates < HTTPServerError
1787
- # 506
1788
2581
  HAS_BODY: bool
1789
2582
  end
1790
2583
 
1791
2584
  class HTTPInsufficientStorage < HTTPServerError
1792
- # 507 - RFC 4918
1793
2585
  HAS_BODY: bool
1794
2586
  end
1795
2587
 
1796
2588
  class HTTPLoopDetected < HTTPServerError
1797
- # 508 - RFC 5842
1798
2589
  HAS_BODY: bool
1799
2590
  end
1800
2591
 
2592
+ # <!-- rdoc-file=lib/net/http/responses.rb -->
2593
+ # 509 Bandwidth Limit Exceeded - Apache bw/limited extension
2594
+ #
1801
2595
  class HTTPNotExtended < HTTPServerError
1802
- # 509 Bandwidth Limit Exceeded - Apache bw/limited extension
1803
- # 510 - RFC 2774
1804
2596
  HAS_BODY: bool
1805
2597
  end
1806
2598
 
1807
2599
  class HTTPNetworkAuthenticationRequired < HTTPServerError
1808
- # 511 - RFC 6585
1809
2600
  HAS_BODY: bool
1810
2601
  end
1811
2602
 
2603
+ # <!-- rdoc-file=lib/net/http/response.rb -->
2604
+ # HTTP response class.
2605
+ #
2606
+ # This class wraps together the response header and the response body (the
2607
+ # entity requested).
2608
+ #
2609
+ # It mixes in the HTTPHeader module, which provides access to response header
2610
+ # values both via hash-like methods and via individual readers.
2611
+ #
2612
+ # Note that each possible HTTP response code defines its own HTTPResponse
2613
+ # subclass. All classes are defined under the Net module. Indentation indicates
2614
+ # inheritance. For a list of the classes see Net::HTTP.
2615
+ #
2616
+ # Correspondence `HTTP code => class` is stored in CODE_TO_OBJ constant:
2617
+ #
2618
+ # Net::HTTPResponse::CODE_TO_OBJ['404'] #=> Net::HTTPNotFound
2619
+ #
1812
2620
  class HTTPResponse
1813
2621
  CODE_CLASS_TO_OBJ: Hash[untyped, untyped]
1814
2622
 
@@ -1817,6 +2625,10 @@ module Net
1817
2625
 
1818
2626
  HTTP::STATUS_CODES: Hash[Integer, String]
1819
2627
 
2628
+ # <!-- rdoc-file=lib/net/http/exceptions.rb -->
2629
+ # Net::HTTP exception class. You cannot use Net::HTTPExceptions directly;
2630
+ # instead, you must use its subclasses.
2631
+ #
1820
2632
  module HTTPExceptions
1821
2633
  def initialize: (untyped msg, untyped res) -> untyped
1822
2634
 
@@ -1838,9 +2650,6 @@ module Net
1838
2650
  include Net::HTTPExceptions
1839
2651
  end
1840
2652
 
1841
- # for compatibility
1842
- # Net::HTTPClientException: untyped
1843
-
1844
2653
  class HTTPFatalError < ProtoFatalError
1845
2654
  include Net::HTTPExceptions
1846
2655
  end