rbs 2.0.0 → 2.2.2

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