rbs 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,7 +59,7 @@ module Mutex_m
59
59
 
60
60
  # See Mutex#sleep
61
61
  #
62
- def sleep: (?Numeric timeout) -> Integer
62
+ def sleep: (?Numeric timeout) -> Integer?
63
63
 
64
64
  alias locked? mu_locked?
65
65
  alias lock mu_lock
@@ -0,0 +1,1846 @@
1
+ module Net
2
+ class Protocol
3
+ VERSION: String
4
+ end
5
+
6
+ class ProtocolError < StandardError
7
+ end
8
+ class ProtoSyntaxError < ProtocolError
9
+ end
10
+ class ProtoFatalError < ProtocolError
11
+ end
12
+ class ProtoUnknownError < ProtocolError
13
+ end
14
+ class ProtoServerError < ProtocolError
15
+ end
16
+ class ProtoAuthError < ProtocolError
17
+ end
18
+ class ProtoCommandError < ProtocolError
19
+ end
20
+ class ProtoRetriableError < ProtocolError
21
+ end
22
+ # ProtocRetryError = ProtoRetriableError
23
+
24
+ # :stopdoc:
25
+ class HTTPBadResponse < StandardError
26
+ end
27
+
28
+ class HTTPHeaderSyntaxError < StandardError
29
+ end
30
+
31
+ # == An HTTP client API for Ruby.
32
+ #
33
+ # Net::HTTP provides a rich library which can be used to build HTTP
34
+ # user-agents. For more details about HTTP see
35
+ # [RFC2616](http://www.ietf.org/rfc/rfc2616.txt).
36
+ #
37
+ # 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.
40
+ #
41
+ # If you are only performing a few GET requests you should try OpenURI.
42
+ #
43
+ # == Simple Examples
44
+ #
45
+ # All examples assume you have loaded Net::HTTP with:
46
+ #
47
+ # require 'net/http'
48
+ #
49
+ # This will also require 'uri' so you don't need to require it separately.
50
+ #
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.
54
+ #
55
+ # === GET
56
+ #
57
+ # Net::HTTP.get('example.com', '/index.html') # => String
58
+ #
59
+ # === GET by URI
60
+ #
61
+ # uri = URI('http://example.com/index.html?count=10')
62
+ # Net::HTTP.get(uri) # => String
63
+ #
64
+ # === GET with Dynamic Parameters
65
+ #
66
+ # uri = URI('http://example.com/index.html')
67
+ # params = { :limit => 10, :page => 3 }
68
+ # uri.query = URI.encode_www_form(params)
69
+ #
70
+ # res = Net::HTTP.get_response(uri)
71
+ # puts res.body if res.is_a?(Net::HTTPSuccess)
72
+ #
73
+ # === POST
74
+ #
75
+ # uri = URI('http://www.example.com/search.cgi')
76
+ # res = Net::HTTP.post_form(uri, 'q' => 'ruby', 'max' => '50')
77
+ # puts res.body
78
+ #
79
+ # === POST with Multiple Values
80
+ #
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
84
+ #
85
+ # == How to use Net::HTTP
86
+ #
87
+ # 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.
90
+ #
91
+ # uri = URI('http://example.com/some_path?query=string')
92
+ #
93
+ # Net::HTTP.start(uri.host, uri.port) do |http|
94
+ # request = Net::HTTP::Get.new uri
95
+ #
96
+ # response = http.request request # Net::HTTPResponse object
97
+ # end
98
+ #
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.
103
+ #
104
+ # 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.
107
+ #
108
+ # The request types Net::HTTP supports are listed below in the section "HTTP
109
+ # Request Classes".
110
+ #
111
+ # 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.
114
+ #
115
+ # === Response Data
116
+ #
117
+ # uri = URI('http://example.com/index.html')
118
+ # res = Net::HTTP.get_response(uri)
119
+ #
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}"
125
+ #
126
+ # # Status
127
+ # puts res.code # => '200'
128
+ # puts res.message # => 'OK'
129
+ # puts res.class.name # => 'HTTPOK'
130
+ #
131
+ # # Body
132
+ # puts res.body if res.response_body_permitted?
133
+ #
134
+ # === Following Redirection
135
+ #
136
+ # Each Net::HTTPResponse object belongs to a class for its response code.
137
+ #
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.
143
+ #
144
+ # Using a case statement you can handle various types of responses properly:
145
+ #
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
161
+ # end
162
+ # end
163
+ #
164
+ # print fetch('http://www.ruby-lang.org')
165
+ #
166
+ # === POST
167
+ #
168
+ # A POST can be made using the Net::HTTP::Post request class. This example
169
+ # creates a URL encoded POST body:
170
+ #
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')
174
+ #
175
+ # res = Net::HTTP.start(uri.hostname, uri.port) do |http|
176
+ # http.request(req)
177
+ # end
178
+ #
179
+ # case res
180
+ # when Net::HTTPSuccess, Net::HTTPRedirection
181
+ # # OK
182
+ # else
183
+ # res.value
184
+ # end
185
+ #
186
+ # To send multipart/form-data use Net::HTTPHeader#set_form:
187
+ #
188
+ # req = Net::HTTP::Post.new(uri)
189
+ # req.set_form([['upload', File.open('foo.bar')]], 'multipart/form-data')
190
+ #
191
+ # Other requests that can contain a body such as PUT can be created in the
192
+ # same way using the corresponding request class (Net::HTTP::Put).
193
+ #
194
+ # === Setting Headers
195
+ #
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.
200
+ #
201
+ # uri = URI('http://example.com/cached_response')
202
+ # file = File.stat 'cached_response'
203
+ #
204
+ # req = Net::HTTP::Get.new(uri)
205
+ # req['If-Modified-Since'] = file.mtime.rfc2822
206
+ #
207
+ # res = Net::HTTP.start(uri.hostname, uri.port) {|http|
208
+ # http.request(req)
209
+ # }
210
+ #
211
+ # open 'cached_response', 'w' do |io|
212
+ # io.write res.body
213
+ # end if res.is_a?(Net::HTTPSuccess)
214
+ #
215
+ # === Basic Authentication
216
+ #
217
+ # Basic authentication is performed according to
218
+ # [RFC2617](http://www.ietf.org/rfc/rfc2617.txt).
219
+ #
220
+ # uri = URI('http://example.com/index.html?key=value')
221
+ #
222
+ # req = Net::HTTP::Get.new(uri)
223
+ # req.basic_auth 'user', 'pass'
224
+ #
225
+ # res = Net::HTTP.start(uri.hostname, uri.port) {|http|
226
+ # http.request(req)
227
+ # }
228
+ # puts res.body
229
+ #
230
+ # === Streaming Response Bodies
231
+ #
232
+ # By default Net::HTTP reads an entire response into memory. If you are
233
+ # handling large files or wish to implement a progress bar you can instead
234
+ # stream the body directly to an IO.
235
+ #
236
+ # uri = URI('http://example.com/large_file')
237
+ #
238
+ # Net::HTTP.start(uri.host, uri.port) do |http|
239
+ # request = Net::HTTP::Get.new uri
240
+ #
241
+ # http.request request do |response|
242
+ # open 'large_file', 'w' do |io|
243
+ # response.read_body do |chunk|
244
+ # io.write chunk
245
+ # end
246
+ # end
247
+ # end
248
+ # end
249
+ #
250
+ # === HTTPS
251
+ #
252
+ # HTTPS is enabled for an HTTP connection by Net::HTTP#use_ssl=.
253
+ #
254
+ # uri = URI('https://secure.example.com/some_path?query=string')
255
+ #
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
260
+ #
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.
264
+ #
265
+ # uri = URI('https://example.com/')
266
+ # Net::HTTP.get(uri) # => String
267
+ #
268
+ # In previous versions of Ruby you would need to require 'net/https' to use
269
+ # HTTPS. This is no longer true.
270
+ #
271
+ # === Proxies
272
+ #
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.
276
+ #
277
+ # You may also create a custom proxy:
278
+ #
279
+ # proxy_addr = 'your.proxy.host'
280
+ # proxy_port = 8080
281
+ #
282
+ # Net::HTTP.new('example.com', nil, proxy_addr, proxy_port).start { |http|
283
+ # # always proxy via your.proxy.addr:8080
284
+ # }
285
+ #
286
+ # See Net::HTTP.new for further details and examples such as proxies that
287
+ # require a username and password.
288
+ #
289
+ # === Compression
290
+ #
291
+ # Net::HTTP automatically adds Accept-Encoding for compression of response
292
+ # bodies and automatically decompresses gzip and deflate responses unless a
293
+ # Range header was sent.
294
+ #
295
+ # Compression can be disabled through the Accept-Encoding: identity header.
296
+ #
297
+ # == HTTP Request Classes
298
+ #
299
+ # Here is the HTTP request class hierarchy.
300
+ #
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.
384
+ #
385
+ class HTTP < Protocol
386
+ # :stopdoc:
387
+ VERSION: String
388
+
389
+ Revision: untyped
390
+
391
+ HTTPVersion: String
392
+
393
+ HAVE_ZLIB: bool
394
+
395
+ # Turns on net/http 1.2 (Ruby 1.8) features.
396
+ # Defaults to ON in Ruby 1.8 or later.
397
+ def self.version_1_2: () -> ::TrueClass
398
+
399
+ # Returns true if net/http is in version 1.2 mode.
400
+ # Defaults to true.
401
+ def self.version_1_2?: () -> ::TrueClass
402
+
403
+ def self.version_1_1?: () -> ::FalseClass
404
+
405
+ alias self.is_version_1_1? self.version_1_1?
406
+
407
+ alias self.is_version_1_2? self.version_1_2?
408
+
409
+ #
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')
415
+ #
416
+ # or:
417
+ #
418
+ # Net::HTTP.get_print 'www.example.com', '/index.html'
419
+ #
420
+ # you can also specify request headers:
421
+ #
422
+ # Net::HTTP.get_print URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' }
423
+ #
424
+ def self.get_print: (URI::Generic uri, ?Hash[String, untyped] header) -> void
425
+ | (String host, String path, ?Integer port) -> void
426
+
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:
430
+ #
431
+ # print Net::HTTP.get(URI('http://www.example.com/index.html'))
432
+ #
433
+ # or:
434
+ #
435
+ # print Net::HTTP.get('www.example.com', '/index.html')
436
+ #
437
+ # you can also specify request headers:
438
+ #
439
+ # Net::HTTP.get(URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' })
440
+ #
441
+ def self.get: (URI::Generic uri, ?Hash[String, untyped] header) -> String
442
+ | (String host, String path, ?Integer port) -> String
443
+
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:
448
+ #
449
+ # res = Net::HTTP.get_response(URI('http://www.example.com/index.html'))
450
+ # print res.body
451
+ #
452
+ # or:
453
+ #
454
+ # res = Net::HTTP.get_response('www.example.com', '/index.html')
455
+ # print res.body
456
+ #
457
+ # you can also specify request headers:
458
+ #
459
+ # Net::HTTP.get_response(URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' })
460
+ #
461
+ def self.get_response: (URI::Generic uri, ?Hash[String, untyped] header) ?{ (Net::HTTPResponse) -> void } -> Net::HTTPResponse
462
+ | (String host, String path, ?Integer port) -> Net::HTTPResponse
463
+
464
+ # Posts data to the specified URI object.
465
+ #
466
+ # Example:
467
+ #
468
+ # require 'net/http'
469
+ # require 'uri'
470
+ #
471
+ # Net::HTTP.post URI('http://www.example.com/api/search'),
472
+ # { "q" => "ruby", "max" => "50" }.to_json,
473
+ # "Content-Type" => "application/json"
474
+ #
475
+ def self.post: (URI::Generic url, String data, ?Hash[String, untyped] header) -> Net::HTTPResponse
476
+
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:
480
+ #
481
+ # { "cmd" => "search", "q" => "ruby", "max" => "50" }
482
+ #
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.
486
+ #
487
+ # Example:
488
+ #
489
+ # require 'net/http'
490
+ #
491
+ # Net::HTTP.post_form URI('http://www.example.com/search.cgi'),
492
+ # { "q" => "ruby", "max" => "50" }
493
+ #
494
+ def self.post_form: (URI::Generic url, Hash[String, untyped] params) -> Net::HTTPResponse
495
+
496
+ # The default port to use for HTTP requests; defaults to 80.
497
+ def self.default_port: () -> Integer
498
+
499
+ # The default port to use for HTTP requests; defaults to 80.
500
+ def self.http_default_port: () -> Integer
501
+
502
+ # The default port to use for HTTPS requests; defaults to 443.
503
+ def self.https_default_port: () -> Integer
504
+
505
+ 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
+ | [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
+
508
+ alias self.newobj self.new
509
+
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.
529
+ #
530
+ 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
+
532
+ def inspect: () -> String
533
+
534
+ # *WARNING* This method opens a serious security hole.
535
+ # Never use this method in production code.
536
+ #
537
+ # Sets an output stream for debugging.
538
+ #
539
+ # http = Net::HTTP.new(hostname)
540
+ # http.set_debug_output $stderr
541
+ # http.start { .... }
542
+ #
543
+ def set_debug_output: (IO output) -> void
544
+
545
+ # The DNS host name or IP address to connect to.
546
+ attr_reader address: String
547
+
548
+ # The port number to connect to.
549
+ attr_reader port: Integer
550
+
551
+ # The local host used to establish the connection.
552
+ attr_accessor local_host: String
553
+
554
+ # The local port used to establish the connection.
555
+ attr_accessor local_port: Integer
556
+
557
+ attr_writer proxy_from_env: untyped
558
+
559
+ attr_accessor proxy_address: String?
560
+
561
+ attr_accessor proxy_port: Integer?
562
+
563
+ attr_accessor proxy_user: String?
564
+
565
+ attr_accessor proxy_pass: String?
566
+
567
+ # The IP address to connect to/used to connect to
568
+ # Set the IP address to connect to
569
+ attr_accessor ipaddr: String?
570
+
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.
581
+ # 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.
589
+ # Setter for the write_timeout attribute.
590
+ attr_accessor write_timeout: (Float | Integer)
591
+
592
+ # 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.
598
+ attr_accessor max_retries: Integer
599
+
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+.
603
+ # Setter for the continue_timeout attribute.
604
+ attr_accessor continue_timeout: (Float | Integer | nil)
605
+
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)
611
+
612
+ # Returns true if the HTTP session has been started.
613
+ def started?: () -> bool
614
+
615
+ alias active? started?
616
+
617
+ attr_accessor close_on_empty_response: untyped
618
+
619
+ # Returns true if SSL/TLS is being used with HTTP.
620
+ def use_ssl?: () -> bool
621
+
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.
626
+ def use_ssl=: (boolish flag) -> void
627
+
628
+ SSL_IVNAMES: Array[untyped]
629
+
630
+ SSL_ATTRIBUTES: Array[Symbol]
631
+
632
+ # Sets path of a CA certification file in PEM format.
633
+ #
634
+ # The file can contain several CA certificates.
635
+ attr_accessor ca_file: untyped
636
+
637
+ # Sets path of a CA certification directory containing certifications in
638
+ # PEM format.
639
+ attr_accessor ca_path: untyped
640
+
641
+ # Sets an OpenSSL::X509::Certificate object as client certificate.
642
+ # (This method is appeared in Michal Rokos's OpenSSL extension).
643
+ attr_accessor cert: untyped
644
+
645
+ # Sets the X509::Store to verify peer certificate.
646
+ attr_accessor cert_store: untyped
647
+
648
+ # Sets the available ciphers. See OpenSSL::SSL::SSLContext#ciphers=
649
+ attr_accessor ciphers: untyped
650
+
651
+ # Sets the extra X509 certificates to be added to the certificate chain.
652
+ # See OpenSSL::SSL::SSLContext#extra_chain_cert=
653
+ attr_accessor extra_chain_cert: untyped
654
+
655
+ # Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
656
+ # (This method is appeared in Michal Rokos's OpenSSL extension.)
657
+ attr_accessor key: untyped
658
+
659
+ # Sets the SSL timeout seconds.
660
+ attr_accessor ssl_timeout: untyped
661
+
662
+ # Sets the SSL version. See OpenSSL::SSL::SSLContext#ssl_version=
663
+ attr_accessor ssl_version: untyped
664
+
665
+ # Sets the minimum SSL version. See OpenSSL::SSL::SSLContext#min_version=
666
+ attr_accessor min_version: untyped
667
+
668
+ # Sets the maximum SSL version. See OpenSSL::SSL::SSLContext#max_version=
669
+ attr_accessor max_version: untyped
670
+
671
+ # Sets the verify callback for the server certification verification.
672
+ attr_accessor verify_callback: untyped
673
+
674
+ # Sets the maximum depth for the certificate chain verification.
675
+ attr_accessor verify_depth: untyped
676
+
677
+ # Sets the flags for server the certification verification at beginning of
678
+ # SSL/TLS session.
679
+ #
680
+ # OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER are acceptable.
681
+ attr_accessor verify_mode: untyped
682
+
683
+ # Sets to check the server certificate is valid for the hostname.
684
+ # See OpenSSL::SSL::SSLContext#verify_hostname=
685
+ attr_accessor verify_hostname: untyped
686
+
687
+ # Returns the X.509 certificates the server presented.
688
+ def peer_cert: () -> (nil | untyped)
689
+
690
+ # Opens a TCP connection and HTTP session.
691
+ #
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.
695
+ #
696
+ # When called with a block, it returns the return value of the
697
+ # block; otherwise, it returns self.
698
+ #
699
+ def start: [T] () { (Net::HTTP) -> T } -> T
700
+ | () -> Net::HTTP
701
+
702
+ public
703
+
704
+ # Finishes the HTTP session and closes the TCP connection.
705
+ # Raises IOError if the session has not been started.
706
+ def finish: () -> void
707
+
708
+ public
709
+
710
+ # Creates an HTTP proxy class which behaves like Net::HTTP, but
711
+ # performs all access via the specified proxy.
712
+ #
713
+ # This class is obsolete. You may pass these same parameters directly to
714
+ # 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
716
+
717
+ # returns true if self is a class which was created by HTTP::Proxy.
718
+ def self.proxy_class?: () -> bool
719
+
720
+ # Address of proxy host. If Net::HTTP does not use a proxy, nil.
721
+ attr_reader self.proxy_address: String?
722
+
723
+ # Port number of proxy host. If Net::HTTP does not use a proxy, nil.
724
+ attr_reader self.proxy_port: Integer?
725
+
726
+ # User name for accessing proxy. If Net::HTTP does not use a proxy, nil.
727
+ attr_reader self.proxy_user: String?
728
+
729
+ # User password for accessing proxy. If Net::HTTP does not use a proxy,
730
+ # nil.
731
+ attr_reader self.proxy_pass: String?
732
+
733
+ # True if requests for this connection will be proxied
734
+ def proxy?: () -> bool
735
+
736
+ # True if the proxy for this connection is determined from the environment
737
+ def proxy_from_env?: () -> bool
738
+
739
+ def proxy_uri: () -> (nil | URI::Generic)
740
+
741
+ alias proxyaddr proxy_address
742
+
743
+ alias proxyport proxy_port
744
+
745
+ public
746
+
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.
762
+ #
763
+ # This method returns a Net::HTTPResponse object.
764
+ #
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.
769
+ #
770
+ # +dest+ argument is obsolete.
771
+ # It still works but you must not use it.
772
+ #
773
+ # This method never raises an exception.
774
+ #
775
+ # response = http.get('/index.html')
776
+ #
777
+ # # using block
778
+ # File.open('result.txt', 'w') {|f|
779
+ # http.get('/~foo/') do |str|
780
+ # f.write str
781
+ # end
782
+ # }
783
+ #
784
+ def get: (String path, ?Hash[String, untyped] initheader, ?bot dest) ?{ (String body_segment) -> void } -> Net::HTTPResponse
785
+
786
+ # Gets only the header from +path+ on the connected-to host.
787
+ # +header+ is a Hash like { 'Accept' => '*/*', ... }.
788
+ #
789
+ # This method returns a Net::HTTPResponse object.
790
+ #
791
+ # This method never raises an exception.
792
+ #
793
+ # response = nil
794
+ # Net::HTTP.start('some.www.server', 80) {|http|
795
+ # response = http.head('/index.html')
796
+ # }
797
+ # p response['content-type']
798
+ #
799
+ def head: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
800
+
801
+ # Posts +data+ (must be a String) to +path+. +header+ must be a Hash
802
+ # like { 'Accept' => '*/*', ... }.
803
+ #
804
+ # This method returns a Net::HTTPResponse object.
805
+ #
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.
810
+ #
811
+ # +dest+ argument is obsolete.
812
+ # It still works but you must not use it.
813
+ #
814
+ # This method never raises exception.
815
+ #
816
+ # response = http.post('/cgi-bin/search.rb', 'query=foo')
817
+ #
818
+ # # using block
819
+ # File.open('result.txt', 'w') {|f|
820
+ # http.post('/cgi-bin/search.rb', 'query=foo') do |str|
821
+ # f.write str
822
+ # end
823
+ # }
824
+ #
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.
828
+ #
829
+ def post: (String path, String data, ?Hash[String, untyped] initheader, ?bot dest) ?{ (String body_segment) -> void } -> Net::HTTPResponse
830
+
831
+ # Sends a PATCH request to the +path+ and gets a response,
832
+ # as an HTTPResponse object.
833
+ def patch: (String path, String data, ?Hash[String, untyped] initheader, ?bot dest) ?{ (String body_segment) -> void } -> Net::HTTPResponse
834
+
835
+ def put: (String path, String data, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
836
+
837
+ # Sends a PROPPATCH request to the +path+ and gets a response,
838
+ # as an HTTPResponse object.
839
+ def proppatch: (String path, String body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
840
+
841
+ # Sends a LOCK request to the +path+ and gets a response,
842
+ # as an HTTPResponse object.
843
+ def lock: (String path, String body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
844
+
845
+ # Sends a UNLOCK request to the +path+ and gets a response,
846
+ # as an HTTPResponse object.
847
+ def unlock: (String path, String body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
848
+
849
+ # Sends a OPTIONS request to the +path+ and gets a response,
850
+ # as an HTTPResponse object.
851
+ def options: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
852
+
853
+ # Sends a PROPFIND request to the +path+ and gets a response,
854
+ # as an HTTPResponse object.
855
+ def propfind: (String path, ?untyped? body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
856
+
857
+ # Sends a DELETE request to the +path+ and gets a response,
858
+ # as an HTTPResponse object.
859
+ def delete: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
860
+
861
+ # Sends a MOVE request to the +path+ and gets a response,
862
+ # as an HTTPResponse object.
863
+ def move: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
864
+
865
+ # Sends a COPY request to the +path+ and gets a response,
866
+ # as an HTTPResponse object.
867
+ def copy: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
868
+
869
+ # Sends a MKCOL request to the +path+ and gets a response,
870
+ # as an HTTPResponse object.
871
+ def mkcol: (String path, ?untyped? body, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
872
+
873
+ # Sends a TRACE request to the +path+ and gets a response,
874
+ # as an HTTPResponse object.
875
+ def trace: (String path, ?Hash[String, untyped] initheader) -> Net::HTTPResponse
876
+
877
+ def request_get: (String path, ?Hash[String, untyped] initheader) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
878
+
879
+ # Sends a HEAD request to the +path+ and returns the response
880
+ # as a Net::HTTPResponse object.
881
+ #
882
+ # Returns the response.
883
+ #
884
+ # This method never raises Net::* exceptions.
885
+ #
886
+ # response = http.request_head('/index.html')
887
+ # p response['content-type']
888
+ #
889
+ def request_head: (String path, ?Hash[String, untyped] initheader) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
890
+
891
+ def request_post: (String path, String data, ?Hash[String, untyped] initheader) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
892
+
893
+ def request_put: (String path, String data, ?Hash[String, untyped] initheader) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
894
+
895
+ alias get2 request_get
896
+
897
+ alias head2 request_head
898
+
899
+ alias post2 request_post
900
+
901
+ alias put2 request_put
902
+
903
+ # Sends an HTTP request to the HTTP server.
904
+ # Also sends a DATA string if +data+ is given.
905
+ #
906
+ # Returns a Net::HTTPResponse object.
907
+ #
908
+ # This method never raises Net::* exceptions.
909
+ #
910
+ # response = http.send_request('GET', '/index.html')
911
+ # puts response.body
912
+ #
913
+ def send_request: (String name, String path, ?String? data, ?Hash[String, untyped]? header) -> Net::HTTPResponse
914
+
915
+ def request: (Net::HTTPRequest req, ?String? body) ?{ (Net::HTTPResponse response) -> void } -> Net::HTTPResponse
916
+
917
+ end
918
+
919
+ class HTTPGenericRequest
920
+ include Net::HTTPHeader
921
+
922
+ def initialize: (String m, boolish reqbody, boolish resbody, (URI::Generic | String) uri_or_path, ?Hash[String, untyped] initheader) -> Net::HTTP
923
+
924
+ attr_reader method: String
925
+
926
+ attr_reader path: String
927
+
928
+ attr_reader uri: URI::Generic
929
+
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.
933
+ attr_reader decode_content: bool
934
+
935
+ def inspect: () -> String
936
+
937
+ def []=: (untyped key, untyped val) -> void
938
+
939
+ def request_body_permitted?: () -> bool
940
+
941
+ def response_body_permitted?: () -> bool
942
+
943
+ def body_exist?: () -> bool
944
+
945
+ attr_accessor body: String?
946
+
947
+ attr_accessor body_stream: untyped
948
+ end
949
+
950
+ module HTTPHeader
951
+ def initialize_http_header: (Hash[untyped, untyped] initheader) -> void
952
+
953
+ def size: () -> Integer
954
+
955
+ alias length size
956
+
957
+ 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"
960
+ def []: (key key) -> (nil | String)
961
+
962
+ # Sets the header field corresponding to the case-insensitive key.
963
+ def []=: (key key, untyped val) -> void
964
+
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"]
979
+ #
980
+ def add_field: (key key, untyped val) -> void
981
+
982
+ private
983
+
984
+ def set_field: (key key, untyped val) -> void
985
+
986
+ def append_field_value: (untyped ary, untyped val) -> void
987
+
988
+ public
989
+
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"
1000
+ #
1001
+ def get_fields: (key key) -> (nil | Array[String])
1002
+
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
1007
+ def fetch: (key key) -> String
1008
+ | (key key, untyped) -> untyped
1009
+ | (key key) { (String) -> untyped } -> untyped
1010
+
1011
+ def each_header: () { (String, String) -> untyped } -> Hash[String, Array[String]]
1012
+ | () -> Enumerator[[String, String], Hash[String, Array[String]]]
1013
+
1014
+ alias each each_header
1015
+
1016
+ def each_name: () { (String) -> untyped } -> Hash[String, Array[String]]
1017
+ | () -> Enumerator[String, Hash[String, Array[String]]]
1018
+
1019
+ alias each_key each_name
1020
+
1021
+ def each_capitalized_name: () { (String) -> untyped } -> Hash[String, Array[String]]
1022
+ | () -> Enumerator[String, Hash[String, Array[String]]]
1023
+
1024
+ def each_value: () { (String) -> untyped } -> Hash[String, Array[String]]
1025
+ | () -> Enumerator[String, Hash[String, Array[String]]]
1026
+
1027
+ # Removes a header field, specified by case-insensitive key.
1028
+ def delete: (key key) -> (Array[String] | nil)
1029
+
1030
+ # true if +key+ header exists.
1031
+ def key?: (key key) -> bool
1032
+
1033
+ # Returns a Hash consisting of header names and array of values.
1034
+ # e.g.
1035
+ # {"cache-control" => ["private"],
1036
+ # "content-type" => ["text/html"],
1037
+ # "date" => ["Wed, 22 Jun 2005 22:11:50 GMT"]}
1038
+ def to_hash: () -> Hash[String, Array[String]]
1039
+
1040
+ # As for #each_header, except the keys are provided in capitalized form.
1041
+ #
1042
+ # Note that header names are capitalized systematically;
1043
+ # capitalization may not match that used by the remote HTTP
1044
+ # server in its response.
1045
+ #
1046
+ # Returns an enumerator if no block is given.
1047
+ def each_capitalized: () { (String, String) -> untyped } -> Hash[String, Array[String]]
1048
+ | () -> Enumerator[[String, String], Hash[String, Array[String]]]
1049
+
1050
+ alias canonical_each each_capitalized
1051
+
1052
+ private
1053
+
1054
+ def capitalize: (key name) -> String
1055
+
1056
+ public
1057
+
1058
+ # Returns an Array of Range objects which represent the Range:
1059
+ # HTTP header field, or +nil+ if there is no such header.
1060
+ def range: () -> (nil | Array[Range[Integer]])
1061
+
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:
1066
+ #
1067
+ # req.range = (0..1023)
1068
+ # req.set_range 0, 1023
1069
+ #
1070
+ def set_range: (Range[Integer] | Numeric r, ?Integer? e) -> Range[Integer]
1071
+
1072
+ alias range= set_range
1073
+
1074
+ # Returns an Integer object which represents the HTTP Content-Length:
1075
+ # header field, or +nil+ if that field was not provided.
1076
+ def content_length: () -> (nil | Integer)
1077
+
1078
+ def content_length=: (Integer len) -> void
1079
+
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.
1084
+ def chunked?: () -> bool
1085
+
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.
1090
+ def content_range: () -> (Range[Integer] | nil)
1091
+
1092
+ # The length of the range represented in Content-Range: header.
1093
+ def range_length: () -> (nil | Integer)
1094
+
1095
+ # Returns a content type string such as "text/html".
1096
+ # This method returns nil if Content-Type: header field does not exist.
1097
+ def content_type: () -> (nil | String)
1098
+
1099
+ # Returns a content type string such as "text".
1100
+ # This method returns nil if Content-Type: header field does not exist.
1101
+ def main_type: () -> (nil | String)
1102
+
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").
1106
+ def sub_type: () -> (nil | String)
1107
+
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'}
1111
+ def type_params: () -> Hash[untyped, untyped]
1112
+
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'}
1117
+ def set_content_type: (key `type`, ?Hash[untyped, untyped] params) -> void
1118
+
1119
+ alias content_type= set_content_type
1120
+
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.
1125
+ #
1126
+ # Values are URL encoded as necessary and the content-type is set to
1127
+ # application/x-www-form-urlencoded
1128
+ #
1129
+ # 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"}, ';')
1133
+ #
1134
+ def set_form_data: (Hash[untyped, untyped] params, ?String sep) -> void
1135
+
1136
+ alias form_data= set_form_data
1137
+
1138
+ # 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.
1168
+ #
1169
+ # Example:
1170
+ # req.set_form([["q", "ruby"], ["lang", "en"]])
1171
+ #
1172
+ # req.set_form({"f"=>File.open('/path/to/filename')},
1173
+ # "multipart/form-data",
1174
+ # charset: "UTF-8",
1175
+ # )
1176
+ #
1177
+ # req.set_form([["f",
1178
+ # File.open('/path/to/filename.bar'),
1179
+ # {filename: "other-filename.foo"}
1180
+ # ]],
1181
+ # "multipart/form-data",
1182
+ # )
1183
+ #
1184
+ # See also RFC 2388, RFC 2616, HTML 4.01, and HTML5
1185
+ #
1186
+ def set_form: (Hash[untyped, untyped] params, ?String enctype, ?Hash[untyped, untyped] formopt) -> void
1187
+
1188
+ # Set the Authorization: header for "Basic" authorization.
1189
+ def basic_auth: (String account, String password) -> void
1190
+
1191
+ # Set Proxy-Authorization: header for "Basic" authorization.
1192
+ def proxy_basic_auth: (String account, String password) -> void
1193
+
1194
+ private
1195
+
1196
+ def basic_encode: (String account, String password) -> String
1197
+
1198
+ public
1199
+
1200
+ def connection_close?: () -> bool
1201
+
1202
+ def connection_keep_alive?: () -> bool
1203
+ end
1204
+
1205
+ class HTTPRequest < HTTPGenericRequest
1206
+ def initialize: (String path, ?Hash[String, untyped] initheader) -> void
1207
+ end
1208
+
1209
+ class HTTP::Get < HTTPRequest
1210
+ METHOD: String
1211
+
1212
+ REQUEST_HAS_BODY: bool
1213
+
1214
+ RESPONSE_HAS_BODY: bool
1215
+ end
1216
+
1217
+ # See Net::HTTPGenericRequest for attributes and methods.
1218
+ # See Net::HTTP for usage examples.
1219
+ class HTTP::Head < HTTPRequest
1220
+ METHOD: String
1221
+
1222
+ REQUEST_HAS_BODY: bool
1223
+
1224
+ RESPONSE_HAS_BODY: bool
1225
+ end
1226
+
1227
+ # See Net::HTTPGenericRequest for attributes and methods.
1228
+ # See Net::HTTP for usage examples.
1229
+ class HTTP::Post < HTTPRequest
1230
+ METHOD: String
1231
+
1232
+ REQUEST_HAS_BODY: bool
1233
+
1234
+ RESPONSE_HAS_BODY: bool
1235
+ end
1236
+
1237
+ # See Net::HTTPGenericRequest for attributes and methods.
1238
+ # See Net::HTTP for usage examples.
1239
+ class HTTP::Put < HTTPRequest
1240
+ METHOD: String
1241
+
1242
+ REQUEST_HAS_BODY: bool
1243
+
1244
+ RESPONSE_HAS_BODY: bool
1245
+ end
1246
+
1247
+ # See Net::HTTPGenericRequest for attributes and methods.
1248
+ # See Net::HTTP for usage examples.
1249
+ class HTTP::Delete < HTTPRequest
1250
+ METHOD: String
1251
+
1252
+ REQUEST_HAS_BODY: bool
1253
+
1254
+ RESPONSE_HAS_BODY: bool
1255
+ end
1256
+
1257
+ # See Net::HTTPGenericRequest for attributes and methods.
1258
+ class HTTP::Options < HTTPRequest
1259
+ METHOD: String
1260
+
1261
+ REQUEST_HAS_BODY: bool
1262
+
1263
+ RESPONSE_HAS_BODY: bool
1264
+ end
1265
+
1266
+ # See Net::HTTPGenericRequest for attributes and methods.
1267
+ class HTTP::Trace < HTTPRequest
1268
+ METHOD: String
1269
+
1270
+ REQUEST_HAS_BODY: bool
1271
+
1272
+ RESPONSE_HAS_BODY: bool
1273
+ end
1274
+
1275
+ # See Net::HTTPGenericRequest for attributes and methods.
1276
+ class HTTP::Patch < HTTPRequest
1277
+ METHOD: String
1278
+
1279
+ REQUEST_HAS_BODY: bool
1280
+
1281
+ RESPONSE_HAS_BODY: bool
1282
+ end
1283
+
1284
+ # See Net::HTTPGenericRequest for attributes and methods.
1285
+ class HTTP::Propfind < HTTPRequest
1286
+ METHOD: String
1287
+
1288
+ REQUEST_HAS_BODY: bool
1289
+
1290
+ RESPONSE_HAS_BODY: bool
1291
+ end
1292
+
1293
+ # See Net::HTTPGenericRequest for attributes and methods.
1294
+ class HTTP::Proppatch < HTTPRequest
1295
+ METHOD: String
1296
+
1297
+ REQUEST_HAS_BODY: bool
1298
+
1299
+ RESPONSE_HAS_BODY: bool
1300
+ end
1301
+
1302
+ # See Net::HTTPGenericRequest for attributes and methods.
1303
+ class HTTP::Mkcol < HTTPRequest
1304
+ METHOD: String
1305
+
1306
+ REQUEST_HAS_BODY: bool
1307
+
1308
+ RESPONSE_HAS_BODY: bool
1309
+ end
1310
+
1311
+ # See Net::HTTPGenericRequest for attributes and methods.
1312
+ class HTTP::Copy < HTTPRequest
1313
+ METHOD: String
1314
+
1315
+ REQUEST_HAS_BODY: bool
1316
+
1317
+ RESPONSE_HAS_BODY: bool
1318
+ end
1319
+
1320
+ # See Net::HTTPGenericRequest for attributes and methods.
1321
+ class HTTP::Move < HTTPRequest
1322
+ METHOD: String
1323
+
1324
+ REQUEST_HAS_BODY: bool
1325
+
1326
+ RESPONSE_HAS_BODY: bool
1327
+ end
1328
+
1329
+ # See Net::HTTPGenericRequest for attributes and methods.
1330
+ class HTTP::Lock < HTTPRequest
1331
+ METHOD: String
1332
+
1333
+ REQUEST_HAS_BODY: bool
1334
+
1335
+ RESPONSE_HAS_BODY: bool
1336
+ end
1337
+
1338
+ # See Net::HTTPGenericRequest for attributes and methods.
1339
+ class HTTP::Unlock < HTTPRequest
1340
+ METHOD: String
1341
+
1342
+ REQUEST_HAS_BODY: bool
1343
+
1344
+ RESPONSE_HAS_BODY: bool
1345
+ end
1346
+
1347
+ class HTTPResponse
1348
+ # true if the response has a body.
1349
+ def self.body_permitted?: () -> bool
1350
+
1351
+ public
1352
+
1353
+ include Net::HTTPHeader
1354
+
1355
+ # The HTTP version supported by the server.
1356
+ attr_reader http_version: String
1357
+
1358
+ # The HTTP result code string. For example, '302'. You can also
1359
+ # determine the response type by examining which response subclass
1360
+ # the response object is an instance of.
1361
+ attr_reader code: String
1362
+
1363
+ # The HTTP result message sent by the server. For example, 'Not Found'.
1364
+ attr_reader message: String
1365
+
1366
+ alias msg message
1367
+
1368
+ # The URI used to fetch this response. The response URI is only available
1369
+ # if a URI was used to create the request.
1370
+ attr_reader uri: (URI::Generic | nil)
1371
+
1372
+ # Set to true automatically when the request did not contain an
1373
+ # Accept-Encoding header from the user.
1374
+ attr_accessor decode_content: bool
1375
+
1376
+ def inspect: () -> String
1377
+
1378
+ def code_type: () -> untyped
1379
+
1380
+ def error!: () -> untyped
1381
+
1382
+ def error_type: () -> (Net::HTTPError | Net::HTTPServerException | Net::HTTPRetriableError | Net::HTTPFatalError)
1383
+
1384
+ # Raises an HTTP error if the response is not 2xx (success).
1385
+ def value: () -> (nil | untyped)
1386
+
1387
+ def uri=: (URI::Generic uri) -> void
1388
+
1389
+ interface _Dest
1390
+ def <<: (String) -> void
1391
+ end
1392
+
1393
+ # Gets the entity body returned by the remote HTTP server.
1394
+ #
1395
+ # If a block is given, the body is passed to the block, and
1396
+ # the body is provided in fragments, as it is read in from the socket.
1397
+ #
1398
+ # If +dest+ argument is given, response is read into that variable,
1399
+ # with <code>dest#<<</code> method (it could be String or IO, or any
1400
+ # other object responding to <code><<</code>).
1401
+ #
1402
+ # Calling this method a second or subsequent time for the same
1403
+ # HTTPResponse object will return the value already read.
1404
+ #
1405
+ # http.request_get('/index.html') {|res|
1406
+ # puts res.read_body
1407
+ # }
1408
+ #
1409
+ # http.request_get('/index.html') {|res|
1410
+ # p res.read_body.object_id # 538149362
1411
+ # p res.read_body.object_id # 538149362
1412
+ # }
1413
+ #
1414
+ # # using iterator
1415
+ # http.request_get('/index.html') {|res|
1416
+ # res.read_body do |segment|
1417
+ # print segment
1418
+ # end
1419
+ # }
1420
+ #
1421
+ def read_body: () -> String
1422
+ | (_Dest dest) -> String
1423
+ | () { (String) -> void } -> String
1424
+
1425
+ # Returns the full entity body.
1426
+ #
1427
+ # Calling this method a second or subsequent time will return the
1428
+ # string already read.
1429
+ #
1430
+ # http.request_get('/index.html') {|res|
1431
+ # puts res.body
1432
+ # }
1433
+ #
1434
+ # http.request_get('/index.html') {|res|
1435
+ # p res.body.object_id # 538149362
1436
+ # p res.body.object_id # 538149362
1437
+ # }
1438
+ #
1439
+ def body: () -> String
1440
+
1441
+ # Because it may be necessary to modify the body, Eg, decompression
1442
+ # this method facilitates that.
1443
+ def body=: (untyped value) -> void
1444
+
1445
+ alias entity body
1446
+ end
1447
+
1448
+ class HTTPUnknownResponse < HTTPResponse
1449
+ HAS_BODY: bool
1450
+
1451
+ EXCEPTION_TYPE: Net::HTTPError
1452
+ end
1453
+
1454
+ class HTTPInformation < HTTPResponse
1455
+ # 1xx
1456
+ HAS_BODY: bool
1457
+
1458
+ EXCEPTION_TYPE: Net::HTTPError
1459
+ end
1460
+
1461
+ class HTTPSuccess < HTTPResponse
1462
+ # 2xx
1463
+ HAS_BODY: bool
1464
+
1465
+ EXCEPTION_TYPE: Net::HTTPError
1466
+ end
1467
+
1468
+ class HTTPRedirection < HTTPResponse
1469
+ # 3xx
1470
+ HAS_BODY: bool
1471
+
1472
+ EXCEPTION_TYPE: Net::HTTPRetriableError
1473
+ end
1474
+
1475
+ class HTTPClientError < HTTPResponse
1476
+ # 4xx
1477
+ HAS_BODY: bool
1478
+
1479
+ # EXCEPTION_TYPE: Net::HTTPClientException -> Change after introduction of class/module alias
1480
+ EXCEPTION_TYPE: untyped
1481
+ end
1482
+
1483
+ class HTTPServerError < HTTPResponse
1484
+ # 5xx
1485
+ HAS_BODY: bool
1486
+
1487
+ EXCEPTION_TYPE: Net::HTTPFatalError
1488
+ end
1489
+
1490
+ class HTTPContinue < HTTPInformation
1491
+ # 100
1492
+ HAS_BODY: bool
1493
+ end
1494
+
1495
+ class HTTPSwitchProtocol < HTTPInformation
1496
+ # 101
1497
+ HAS_BODY: bool
1498
+ end
1499
+
1500
+ class HTTPProcessing < HTTPInformation
1501
+ # 102
1502
+ HAS_BODY: bool
1503
+ end
1504
+
1505
+ class HTTPEarlyHints < HTTPInformation
1506
+ # 103 - RFC 8297
1507
+ HAS_BODY: bool
1508
+ end
1509
+
1510
+ class HTTPOK < HTTPSuccess
1511
+ # 200
1512
+ HAS_BODY: bool
1513
+ end
1514
+
1515
+ class HTTPCreated < HTTPSuccess
1516
+ # 201
1517
+ HAS_BODY: bool
1518
+ end
1519
+
1520
+ class HTTPAccepted < HTTPSuccess
1521
+ # 202
1522
+ HAS_BODY: bool
1523
+ end
1524
+
1525
+ class HTTPNonAuthoritativeInformation < HTTPSuccess
1526
+ # 203
1527
+ HAS_BODY: bool
1528
+ end
1529
+
1530
+ class HTTPNoContent < HTTPSuccess
1531
+ # 204
1532
+ HAS_BODY: bool
1533
+ end
1534
+
1535
+ class HTTPResetContent < HTTPSuccess
1536
+ # 205
1537
+ HAS_BODY: bool
1538
+ end
1539
+
1540
+ class HTTPPartialContent < HTTPSuccess
1541
+ # 206
1542
+ HAS_BODY: bool
1543
+ end
1544
+
1545
+ class HTTPMultiStatus < HTTPSuccess
1546
+ # 207 - RFC 4918
1547
+ HAS_BODY: bool
1548
+ end
1549
+
1550
+ class HTTPAlreadyReported < HTTPSuccess
1551
+ # 208 - RFC 5842
1552
+ HAS_BODY: bool
1553
+ end
1554
+
1555
+ class HTTPIMUsed < HTTPSuccess
1556
+ # 226 - RFC 3229
1557
+ HAS_BODY: bool
1558
+ end
1559
+
1560
+ class HTTPMultipleChoices < HTTPRedirection
1561
+ # 300
1562
+ HAS_BODY: bool
1563
+ end
1564
+
1565
+ HTTPMultipleChoice: HTTPMultipleChoices
1566
+
1567
+ class HTTPMovedPermanently < HTTPRedirection
1568
+ # 301
1569
+ HAS_BODY: bool
1570
+ end
1571
+
1572
+ class HTTPFound < HTTPRedirection
1573
+ # 302
1574
+ HAS_BODY: bool
1575
+ end
1576
+
1577
+ # HTTPMovedTemporarily: HTTPFound
1578
+
1579
+ class HTTPSeeOther < HTTPRedirection
1580
+ # 303
1581
+ HAS_BODY: bool
1582
+ end
1583
+
1584
+ class HTTPNotModified < HTTPRedirection
1585
+ # 304
1586
+ HAS_BODY: bool
1587
+ end
1588
+
1589
+ class HTTPUseProxy < HTTPRedirection
1590
+ # 305
1591
+ HAS_BODY: bool
1592
+ end
1593
+
1594
+ class HTTPTemporaryRedirect < HTTPRedirection
1595
+ # 306 Switch Proxy - no longer unused
1596
+ # 307
1597
+ HAS_BODY: bool
1598
+ end
1599
+
1600
+ class HTTPPermanentRedirect < HTTPRedirection
1601
+ # 308
1602
+ HAS_BODY: bool
1603
+ end
1604
+
1605
+ class HTTPBadRequest < HTTPClientError
1606
+ # 400
1607
+ HAS_BODY: bool
1608
+ end
1609
+
1610
+ class HTTPUnauthorized < HTTPClientError
1611
+ # 401
1612
+ HAS_BODY: bool
1613
+ end
1614
+
1615
+ class HTTPPaymentRequired < HTTPClientError
1616
+ # 402
1617
+ HAS_BODY: bool
1618
+ end
1619
+
1620
+ class HTTPForbidden < HTTPClientError
1621
+ # 403
1622
+ HAS_BODY: bool
1623
+ end
1624
+
1625
+ class HTTPNotFound < HTTPClientError
1626
+ # 404
1627
+ HAS_BODY: bool
1628
+ end
1629
+
1630
+ class HTTPMethodNotAllowed < HTTPClientError
1631
+ # 405
1632
+ HAS_BODY: bool
1633
+ end
1634
+
1635
+ class HTTPNotAcceptable < HTTPClientError
1636
+ # 406
1637
+ HAS_BODY: bool
1638
+ end
1639
+
1640
+ class HTTPProxyAuthenticationRequired < HTTPClientError
1641
+ # 407
1642
+ HAS_BODY: bool
1643
+ end
1644
+
1645
+ class HTTPRequestTimeout < HTTPClientError
1646
+ # 408
1647
+ HAS_BODY: bool
1648
+ end
1649
+
1650
+ # HTTPRequestTimeOut: HTTPRequestTimeout
1651
+
1652
+ class HTTPConflict < HTTPClientError
1653
+ # 409
1654
+ HAS_BODY: bool
1655
+ end
1656
+
1657
+ class HTTPGone < HTTPClientError
1658
+ # 410
1659
+ HAS_BODY: bool
1660
+ end
1661
+
1662
+ class HTTPLengthRequired < HTTPClientError
1663
+ # 411
1664
+ HAS_BODY: bool
1665
+ end
1666
+
1667
+ class HTTPPreconditionFailed < HTTPClientError
1668
+ # 412
1669
+ HAS_BODY: bool
1670
+ end
1671
+
1672
+ class HTTPPayloadTooLarge < HTTPClientError
1673
+ # 413
1674
+ HAS_BODY: bool
1675
+ end
1676
+
1677
+ # HTTPRequestEntityTooLarge: untyped
1678
+
1679
+ class HTTPURITooLong < HTTPClientError
1680
+ # 414
1681
+ HAS_BODY: bool
1682
+ end
1683
+
1684
+ # HTTPRequestURITooLong: untyped
1685
+
1686
+ # HTTPRequestURITooLarge: untyped
1687
+
1688
+ class HTTPUnsupportedMediaType < HTTPClientError
1689
+ # 415
1690
+ HAS_BODY: bool
1691
+ end
1692
+
1693
+ class HTTPRangeNotSatisfiable < HTTPClientError
1694
+ # 416
1695
+ HAS_BODY: bool
1696
+ end
1697
+
1698
+ # HTTPRequestedRangeNotSatisfiable: untyped
1699
+
1700
+ class HTTPExpectationFailed < HTTPClientError
1701
+ # 417
1702
+ HAS_BODY: bool
1703
+ end
1704
+
1705
+ class HTTPMisdirectedRequest < HTTPClientError
1706
+ # 418 I'm a teapot - RFC 2324; a joke RFC
1707
+ # 420 Enhance Your Calm - Twitter
1708
+ # 421 - RFC 7540
1709
+ HAS_BODY: bool
1710
+ end
1711
+
1712
+ class HTTPUnprocessableEntity < HTTPClientError
1713
+ # 422 - RFC 4918
1714
+ HAS_BODY: bool
1715
+ end
1716
+
1717
+ class HTTPLocked < HTTPClientError
1718
+ # 423 - RFC 4918
1719
+ HAS_BODY: bool
1720
+ end
1721
+
1722
+ class HTTPFailedDependency < HTTPClientError
1723
+ # 424 - RFC 4918
1724
+ HAS_BODY: bool
1725
+ end
1726
+
1727
+ class HTTPUpgradeRequired < HTTPClientError
1728
+ # 425 Unordered Collection - existed only in draft
1729
+ # 426 - RFC 2817
1730
+ HAS_BODY: bool
1731
+ end
1732
+
1733
+ class HTTPPreconditionRequired < HTTPClientError
1734
+ # 428 - RFC 6585
1735
+ HAS_BODY: bool
1736
+ end
1737
+
1738
+ class HTTPTooManyRequests < HTTPClientError
1739
+ # 429 - RFC 6585
1740
+ HAS_BODY: bool
1741
+ end
1742
+
1743
+ class HTTPRequestHeaderFieldsTooLarge < HTTPClientError
1744
+ # 431 - RFC 6585
1745
+ HAS_BODY: bool
1746
+ end
1747
+
1748
+ class HTTPUnavailableForLegalReasons < HTTPClientError
1749
+ # 451 - RFC 7725
1750
+ HAS_BODY: bool
1751
+ end
1752
+
1753
+ class HTTPInternalServerError < HTTPServerError
1754
+ # 500
1755
+ HAS_BODY: bool
1756
+ end
1757
+
1758
+ class HTTPNotImplemented < HTTPServerError
1759
+ # 501
1760
+ HAS_BODY: bool
1761
+ end
1762
+
1763
+ class HTTPBadGateway < HTTPServerError
1764
+ # 502
1765
+ HAS_BODY: bool
1766
+ end
1767
+
1768
+ class HTTPServiceUnavailable < HTTPServerError
1769
+ # 503
1770
+ HAS_BODY: bool
1771
+ end
1772
+
1773
+ class HTTPGatewayTimeout < HTTPServerError
1774
+ # 504
1775
+ HAS_BODY: bool
1776
+ end
1777
+
1778
+ # HTTPGatewayTimeOut: untyped
1779
+
1780
+ class HTTPVersionNotSupported < HTTPServerError
1781
+ # 505
1782
+ HAS_BODY: bool
1783
+ end
1784
+
1785
+ class HTTPVariantAlsoNegotiates < HTTPServerError
1786
+ # 506
1787
+ HAS_BODY: bool
1788
+ end
1789
+
1790
+ class HTTPInsufficientStorage < HTTPServerError
1791
+ # 507 - RFC 4918
1792
+ HAS_BODY: bool
1793
+ end
1794
+
1795
+ class HTTPLoopDetected < HTTPServerError
1796
+ # 508 - RFC 5842
1797
+ HAS_BODY: bool
1798
+ end
1799
+
1800
+ class HTTPNotExtended < HTTPServerError
1801
+ # 509 Bandwidth Limit Exceeded - Apache bw/limited extension
1802
+ # 510 - RFC 2774
1803
+ HAS_BODY: bool
1804
+ end
1805
+
1806
+ class HTTPNetworkAuthenticationRequired < HTTPServerError
1807
+ # 511 - RFC 6585
1808
+ HAS_BODY: bool
1809
+ end
1810
+
1811
+ class HTTPResponse
1812
+ CODE_CLASS_TO_OBJ: Hash[untyped, untyped]
1813
+
1814
+ CODE_TO_OBJ: Hash[untyped, untyped]
1815
+ end
1816
+
1817
+ HTTP::STATUS_CODES: Hash[Integer, String]
1818
+
1819
+ module HTTPExceptions
1820
+ def initialize: (untyped msg, untyped res) -> untyped
1821
+
1822
+ attr_reader response: untyped
1823
+
1824
+ alias data response
1825
+ end
1826
+
1827
+ class HTTPError < ProtocolError
1828
+ include Net::HTTPExceptions
1829
+ end
1830
+
1831
+ class HTTPRetriableError < ProtoRetriableError
1832
+ include Net::HTTPExceptions
1833
+ end
1834
+
1835
+ class HTTPServerException < ProtoServerError
1836
+ # We cannot use the name "HTTPServerError", it is the name of the response.
1837
+ include Net::HTTPExceptions
1838
+ end
1839
+
1840
+ # for compatibility
1841
+ # Net::HTTPClientException: untyped
1842
+
1843
+ class HTTPFatalError < ProtoFatalError
1844
+ include Net::HTTPExceptions
1845
+ end
1846
+ end