ruby-lsp 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/VERSION +1 -1
  4. data/lib/ruby_lsp/handler.rb +0 -19
  5. data/lib/ruby_lsp/requests/document_link.rb +59 -0
  6. data/lib/ruby_lsp/requests/semantic_highlighting.rb +11 -5
  7. data/lib/ruby_lsp/requests/support/highlight_target.rb +2 -1
  8. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +9 -2
  9. data/lib/ruby_lsp/requests.rb +2 -0
  10. data/lib/ruby_lsp/server.rb +51 -19
  11. metadata +3 -69
  12. data/.github/dependabot.yml +0 -11
  13. data/.github/probots.yml +0 -2
  14. data/.github/pull_request_template.md +0 -15
  15. data/.github/workflows/ci.yml +0 -31
  16. data/.github/workflows/publish_docs.yml +0 -32
  17. data/.gitignore +0 -9
  18. data/.rubocop.yml +0 -40
  19. data/.vscode/extensions.json +0 -5
  20. data/.vscode/settings.json +0 -5
  21. data/.vscode/tasks.json +0 -25
  22. data/CODE_OF_CONDUCT.md +0 -78
  23. data/Gemfile +0 -18
  24. data/Gemfile.lock +0 -126
  25. data/Rakefile +0 -28
  26. data/bin/console +0 -19
  27. data/bin/rubocop +0 -29
  28. data/bin/tapioca +0 -29
  29. data/bin/test +0 -9
  30. data/dev.yml +0 -20
  31. data/rakelib/check_docs.rake +0 -81
  32. data/ruby-lsp.gemspec +0 -27
  33. data/service.yml +0 -2
  34. data/sorbet/config +0 -4
  35. data/sorbet/rbi/.rubocop.yml +0 -8
  36. data/sorbet/rbi/gems/ansi@1.5.0.rbi +0 -338
  37. data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -522
  38. data/sorbet/rbi/gems/builder@3.2.4.rbi +0 -418
  39. data/sorbet/rbi/gems/coderay@1.1.3.rbi +0 -8
  40. data/sorbet/rbi/gems/debug@1.5.0.rbi +0 -1273
  41. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +0 -867
  42. data/sorbet/rbi/gems/io-console@0.5.11.rbi +0 -8
  43. data/sorbet/rbi/gems/irb@1.4.1.rbi +0 -376
  44. data/sorbet/rbi/gems/language_server-protocol@3.16.0.3.rbi +0 -7325
  45. data/sorbet/rbi/gems/method_source@1.0.0.rbi +0 -8
  46. data/sorbet/rbi/gems/minitest-reporters@1.5.0.rbi +0 -612
  47. data/sorbet/rbi/gems/minitest@5.15.0.rbi +0 -994
  48. data/sorbet/rbi/gems/parallel@1.22.1.rbi +0 -163
  49. data/sorbet/rbi/gems/parser@3.1.2.0.rbi +0 -3968
  50. data/sorbet/rbi/gems/prettier_print@0.1.0.rbi +0 -734
  51. data/sorbet/rbi/gems/pry@0.14.1.rbi +0 -8
  52. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +0 -227
  53. data/sorbet/rbi/gems/rake@13.0.6.rbi +0 -1853
  54. data/sorbet/rbi/gems/rbi@0.0.14.rbi +0 -2337
  55. data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +0 -1854
  56. data/sorbet/rbi/gems/reline@0.3.1.rbi +0 -1274
  57. data/sorbet/rbi/gems/rexml@3.2.5.rbi +0 -3852
  58. data/sorbet/rbi/gems/rubocop-ast@1.18.0.rbi +0 -4180
  59. data/sorbet/rbi/gems/rubocop-minitest@0.20.0.rbi +0 -1369
  60. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +0 -246
  61. data/sorbet/rbi/gems/rubocop-shopify@2.6.0.rbi +0 -8
  62. data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +0 -652
  63. data/sorbet/rbi/gems/rubocop@1.30.0.rbi +0 -36729
  64. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +0 -732
  65. data/sorbet/rbi/gems/spoom@1.1.11.rbi +0 -1600
  66. data/sorbet/rbi/gems/syntax_tree@2.7.1.rbi +0 -6777
  67. data/sorbet/rbi/gems/tapioca@0.8.1.rbi +0 -1972
  68. data/sorbet/rbi/gems/thor@1.2.1.rbi +0 -2921
  69. data/sorbet/rbi/gems/unicode-display_width@2.1.0.rbi +0 -27
  70. data/sorbet/rbi/gems/unparser@0.6.5.rbi +0 -2789
  71. data/sorbet/rbi/gems/webrick@1.7.0.rbi +0 -1779
  72. data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +0 -289
  73. data/sorbet/rbi/gems/yard@0.9.27.rbi +0 -13048
  74. data/sorbet/rbi/shims/fiddle.rbi +0 -4
  75. data/sorbet/rbi/shims/hash.rbi +0 -6
  76. data/sorbet/rbi/shims/rdoc.rbi +0 -4
  77. data/sorbet/tapioca/config.yml +0 -13
  78. data/sorbet/tapioca/require.rb +0 -7
@@ -1,1779 +0,0 @@
1
- # typed: true
2
-
3
- # DO NOT EDIT MANUALLY
4
- # This is an autogenerated file for types exported from the `webrick` gem.
5
- # Please instead update this file by running `bin/tapioca gem webrick`.
6
-
7
- # AccessLog provides logging to various files in various formats.
8
- #
9
- # Multiple logs may be written to at the same time:
10
- #
11
- # access_log = [
12
- # [$stderr, WEBrick::AccessLog::COMMON_LOG_FORMAT],
13
- # [$stderr, WEBrick::AccessLog::REFERER_LOG_FORMAT],
14
- # ]
15
- #
16
- # server = WEBrick::HTTPServer.new :AccessLog => access_log
17
- #
18
- # Custom log formats may be defined. WEBrick::AccessLog provides a subset
19
- # of the formatting from Apache's mod_log_config
20
- # http://httpd.apache.org/docs/mod/mod_log_config.html#formats. See
21
- # AccessLog::setup_params for a list of supported options
22
- module WEBrick::AccessLog
23
- private
24
-
25
- # Escapes control characters in +data+
26
- def escape(data); end
27
-
28
- # Formats +params+ according to +format_string+ which is described in
29
- # setup_params.
30
- def format(format_string, params); end
31
-
32
- # This format specification is a subset of mod_log_config of Apache:
33
- #
34
- # %a:: Remote IP address
35
- # %b:: Total response size
36
- # %e{variable}:: Given variable in ENV
37
- # %f:: Response filename
38
- # %h:: Remote host name
39
- # %{header}i:: Given request header
40
- # %l:: Remote logname, always "-"
41
- # %m:: Request method
42
- # %{attr}n:: Given request attribute from <tt>req.attributes</tt>
43
- # %{header}o:: Given response header
44
- # %p:: Server's request port
45
- # %{format}p:: The canonical port of the server serving the request or the
46
- # actual port or the client's actual port. Valid formats are
47
- # canonical, local or remote.
48
- # %q:: Request query string
49
- # %r:: First line of the request
50
- # %s:: Request status
51
- # %t:: Time the request was received
52
- # %T:: Time taken to process the request
53
- # %u:: Remote user from auth
54
- # %U:: Unparsed URI
55
- # %%:: Literal %
56
- def setup_params(config, req, res); end
57
-
58
- class << self
59
- # Escapes control characters in +data+
60
- def escape(data); end
61
-
62
- # Formats +params+ according to +format_string+ which is described in
63
- # setup_params.
64
- def format(format_string, params); end
65
-
66
- # This format specification is a subset of mod_log_config of Apache:
67
- #
68
- # %a:: Remote IP address
69
- # %b:: Total response size
70
- # %e{variable}:: Given variable in ENV
71
- # %f:: Response filename
72
- # %h:: Remote host name
73
- # %{header}i:: Given request header
74
- # %l:: Remote logname, always "-"
75
- # %m:: Request method
76
- # %{attr}n:: Given request attribute from <tt>req.attributes</tt>
77
- # %{header}o:: Given response header
78
- # %p:: Server's request port
79
- # %{format}p:: The canonical port of the server serving the request or the
80
- # actual port or the client's actual port. Valid formats are
81
- # canonical, local or remote.
82
- # %q:: Request query string
83
- # %r:: First line of the request
84
- # %s:: Request status
85
- # %t:: Time the request was received
86
- # %T:: Time taken to process the request
87
- # %u:: Remote user from auth
88
- # %U:: Unparsed URI
89
- # %%:: Literal %
90
- def setup_params(config, req, res); end
91
- end
92
- end
93
-
94
- # A generic logging class
95
- class WEBrick::BasicLog
96
- # Initializes a new logger for +log_file+ that outputs messages at +level+
97
- # or higher. +log_file+ can be a filename, an IO-like object that
98
- # responds to #<< or nil which outputs to $stderr.
99
- #
100
- # If no level is given INFO is chosen by default
101
- #
102
- # @return [BasicLog] a new instance of BasicLog
103
- def initialize(log_file = T.unsafe(nil), level = T.unsafe(nil)); end
104
-
105
- # Synonym for log(INFO, obj.to_s)
106
- def <<(obj); end
107
-
108
- # Closes the logger (also closes the log device associated to the logger)
109
- def close; end
110
-
111
- # Shortcut for logging a DEBUG message
112
- def debug(msg); end
113
-
114
- # Will the logger output DEBUG messages?
115
- #
116
- # @return [Boolean]
117
- def debug?; end
118
-
119
- # Shortcut for logging an ERROR message
120
- def error(msg); end
121
-
122
- # Will the logger output ERROR messages?
123
- #
124
- # @return [Boolean]
125
- def error?; end
126
-
127
- # Shortcut for logging a FATAL message
128
- def fatal(msg); end
129
-
130
- # Will the logger output FATAL messages?
131
- #
132
- # @return [Boolean]
133
- def fatal?; end
134
-
135
- # Shortcut for logging an INFO message
136
- def info(msg); end
137
-
138
- # Will the logger output INFO messages?
139
- #
140
- # @return [Boolean]
141
- def info?; end
142
-
143
- # log-level, messages above this level will be logged
144
- def level; end
145
-
146
- # log-level, messages above this level will be logged
147
- def level=(_arg0); end
148
-
149
- # Logs +data+ at +level+ if the given level is above the current log
150
- # level.
151
- def log(level, data); end
152
-
153
- # Shortcut for logging a WARN message
154
- def warn(msg); end
155
-
156
- # Will the logger output WARN messages?
157
- #
158
- # @return [Boolean]
159
- def warn?; end
160
-
161
- private
162
-
163
- # Formats +arg+ for the logger
164
- #
165
- # * If +arg+ is an Exception, it will format the error message and
166
- # the back trace.
167
- # * If +arg+ responds to #to_str, it will return it.
168
- # * Otherwise it will return +arg+.inspect.
169
- def format(arg); end
170
- end
171
-
172
- # --
173
- # Updates WEBrick::GenericServer with SSL functionality
174
- class WEBrick::GenericServer
175
- # Creates a new generic server from +config+. The default configuration
176
- # comes from +default+.
177
- #
178
- # @return [GenericServer] a new instance of GenericServer
179
- def initialize(config = T.unsafe(nil), default = T.unsafe(nil)); end
180
-
181
- # Retrieves +key+ from the configuration
182
- def [](key); end
183
-
184
- # The server configuration
185
- def config; end
186
-
187
- # Updates +listen+ to enable SSL when the SSL configuration is active.
188
- def listen(address, port); end
189
-
190
- # Sockets listening for connections.
191
- def listeners; end
192
-
193
- # The server logger. This is independent from the HTTP access log.
194
- def logger; end
195
-
196
- # You must subclass GenericServer and implement \#run which accepts a TCP
197
- # client socket
198
- def run(sock); end
199
-
200
- # Shuts down the server and all listening sockets. New listeners must be
201
- # provided to restart the server.
202
- def shutdown; end
203
-
204
- # Starts the server and runs the +block+ for each connection. This method
205
- # does not return until the server is stopped from a signal handler or
206
- # another thread using #stop or #shutdown.
207
- #
208
- # If the block raises a subclass of StandardError the exception is logged
209
- # and ignored. If an IOError or Errno::EBADF exception is raised the
210
- # exception is ignored. If an Exception subclass is raised the exception
211
- # is logged and re-raised which stops the server.
212
- #
213
- # To completely shut down a server call #shutdown from ensure:
214
- #
215
- # server = WEBrick::GenericServer.new
216
- # # or WEBrick::HTTPServer.new
217
- #
218
- # begin
219
- # server.start
220
- # ensure
221
- # server.shutdown
222
- # end
223
- #
224
- # @raise [ServerError]
225
- def start(&block); end
226
-
227
- # The server status. One of :Stop, :Running or :Shutdown
228
- def status; end
229
-
230
- # Stops the server from accepting new connections.
231
- def stop; end
232
-
233
- # Tokens control the number of outstanding clients. The
234
- # <code>:MaxClients</code> configuration sets this.
235
- def tokens; end
236
-
237
- private
238
-
239
- # Accepts a TCP client socket from the TCP server socket +svr+ and returns
240
- # the client socket.
241
- def accept_client(svr); end
242
-
243
- def alarm_shutdown_pipe; end
244
-
245
- # Calls the callback +callback_name+ from the configuration with +args+
246
- def call_callback(callback_name, *args); end
247
-
248
- def cleanup_listener; end
249
- def cleanup_shutdown_pipe(shutdown_pipe); end
250
- def setup_shutdown_pipe; end
251
-
252
- # Starts a server thread for the client socket +sock+ that runs the given
253
- # +block+.
254
- #
255
- # Sets the socket to the <code>:WEBrickSocket</code> thread local variable
256
- # in the thread.
257
- #
258
- # If any errors occur in the block they are logged and handled.
259
- def start_thread(sock, &block); end
260
- end
261
-
262
- module WEBrick::HTMLUtils
263
- private
264
-
265
- # Escapes &, ", > and < in +string+
266
- def escape(string); end
267
-
268
- class << self
269
- # Escapes &, ", > and < in +string+
270
- def escape(string); end
271
- end
272
- end
273
-
274
- # HTTPAuth provides both basic and digest authentication.
275
- #
276
- # To enable authentication for requests in WEBrick you will need a user
277
- # database and an authenticator. To start, here's an Htpasswd database for
278
- # use with a DigestAuth authenticator:
279
- #
280
- # config = { :Realm => 'DigestAuth example realm' }
281
- #
282
- # htpasswd = WEBrick::HTTPAuth::Htpasswd.new 'my_password_file'
283
- # htpasswd.auth_type = WEBrick::HTTPAuth::DigestAuth
284
- # htpasswd.set_passwd config[:Realm], 'username', 'password'
285
- # htpasswd.flush
286
- #
287
- # The +:Realm+ is used to provide different access to different groups
288
- # across several resources on a server. Typically you'll need only one
289
- # realm for a server.
290
- #
291
- # This database can be used to create an authenticator:
292
- #
293
- # config[:UserDB] = htpasswd
294
- #
295
- # digest_auth = WEBrick::HTTPAuth::DigestAuth.new config
296
- #
297
- # To authenticate a request call #authenticate with a request and response
298
- # object in a servlet:
299
- #
300
- # def do_GET req, res
301
- # @authenticator.authenticate req, res
302
- # end
303
- #
304
- # For digest authentication the authenticator must not be created every
305
- # request, it must be passed in as an option via WEBrick::HTTPServer#mount.
306
- module WEBrick::HTTPAuth
307
- private
308
-
309
- def _basic_auth(req, res, realm, req_field, res_field, err_type, block); end
310
-
311
- # Simple wrapper for providing basic authentication for a request. When
312
- # called with a request +req+, response +res+, authentication +realm+ and
313
- # +block+ the block will be called with a +username+ and +password+. If
314
- # the block returns true the request is allowed to continue, otherwise an
315
- # HTTPStatus::Unauthorized error is raised.
316
- def basic_auth(req, res, realm, &block); end
317
-
318
- # Simple wrapper for providing basic authentication for a proxied request.
319
- # When called with a request +req+, response +res+, authentication +realm+
320
- # and +block+ the block will be called with a +username+ and +password+.
321
- # If the block returns true the request is allowed to continue, otherwise
322
- # an HTTPStatus::ProxyAuthenticationRequired error is raised.
323
- def proxy_basic_auth(req, res, realm, &block); end
324
-
325
- class << self
326
- def _basic_auth(req, res, realm, req_field, res_field, err_type, block); end
327
-
328
- # Simple wrapper for providing basic authentication for a request. When
329
- # called with a request +req+, response +res+, authentication +realm+ and
330
- # +block+ the block will be called with a +username+ and +password+. If
331
- # the block returns true the request is allowed to continue, otherwise an
332
- # HTTPStatus::Unauthorized error is raised.
333
- def basic_auth(req, res, realm, &block); end
334
-
335
- # Simple wrapper for providing basic authentication for a proxied request.
336
- # When called with a request +req+, response +res+, authentication +realm+
337
- # and +block+ the block will be called with a +username+ and +password+.
338
- # If the block returns true the request is allowed to continue, otherwise
339
- # an HTTPStatus::ProxyAuthenticationRequired error is raised.
340
- def proxy_basic_auth(req, res, realm, &block); end
341
- end
342
- end
343
-
344
- # Module providing generic support for both Digest and Basic
345
- # authentication schemes.
346
- module WEBrick::HTTPAuth::Authenticator
347
- # The logger for this authenticator
348
- def logger; end
349
-
350
- # The realm this authenticator covers
351
- def realm; end
352
-
353
- # The user database for this authenticator
354
- def userdb; end
355
-
356
- private
357
-
358
- # Initializes the authenticator from +config+
359
- def check_init(config); end
360
-
361
- # Ensures +req+ has credentials that can be authenticated.
362
- def check_scheme(req); end
363
-
364
- def error(fmt, *args); end
365
- def info(fmt, *args); end
366
- def log(meth, fmt, *args); end
367
- end
368
-
369
- WEBrick::HTTPAuth::Authenticator::AuthException = WEBrick::HTTPStatus::Unauthorized
370
-
371
- # Basic Authentication for WEBrick
372
- #
373
- # Use this class to add basic authentication to a WEBrick servlet.
374
- #
375
- # Here is an example of how to set up a BasicAuth:
376
- #
377
- # config = { :Realm => 'BasicAuth example realm' }
378
- #
379
- # htpasswd = WEBrick::HTTPAuth::Htpasswd.new 'my_password_file', password_hash: :bcrypt
380
- # htpasswd.set_passwd config[:Realm], 'username', 'password'
381
- # htpasswd.flush
382
- #
383
- # config[:UserDB] = htpasswd
384
- #
385
- # basic_auth = WEBrick::HTTPAuth::BasicAuth.new config
386
- class WEBrick::HTTPAuth::BasicAuth
387
- include ::WEBrick::HTTPAuth::Authenticator
388
-
389
- # Creates a new BasicAuth instance.
390
- #
391
- # See WEBrick::Config::BasicAuth for default configuration entries
392
- #
393
- # You must supply the following configuration entries:
394
- #
395
- # :Realm:: The name of the realm being protected.
396
- # :UserDB:: A database of usernames and passwords.
397
- # A WEBrick::HTTPAuth::Htpasswd instance should be used.
398
- #
399
- # @return [BasicAuth] a new instance of BasicAuth
400
- def initialize(config, default = T.unsafe(nil)); end
401
-
402
- # Authenticates a +req+ and returns a 401 Unauthorized using +res+ if
403
- # the authentication was not correct.
404
- def authenticate(req, res); end
405
-
406
- # Returns a challenge response which asks for authentication information
407
- #
408
- # @raise [@auth_exception]
409
- def challenge(req, res); end
410
-
411
- # Returns the value of attribute logger.
412
- def logger; end
413
-
414
- # Returns the value of attribute realm.
415
- def realm; end
416
-
417
- # Returns the value of attribute userdb.
418
- def userdb; end
419
-
420
- class << self
421
- # Used by UserDB to create a basic password entry
422
- def make_passwd(realm, user, pass); end
423
- end
424
- end
425
-
426
- # RFC 2617 Digest Access Authentication for WEBrick
427
- #
428
- # Use this class to add digest authentication to a WEBrick servlet.
429
- #
430
- # Here is an example of how to set up DigestAuth:
431
- #
432
- # config = { :Realm => 'DigestAuth example realm' }
433
- #
434
- # htdigest = WEBrick::HTTPAuth::Htdigest.new 'my_password_file'
435
- # htdigest.set_passwd config[:Realm], 'username', 'password'
436
- # htdigest.flush
437
- #
438
- # config[:UserDB] = htdigest
439
- #
440
- # digest_auth = WEBrick::HTTPAuth::DigestAuth.new config
441
- #
442
- # When using this as with a servlet be sure not to create a new DigestAuth
443
- # object in the servlet's #initialize. By default WEBrick creates a new
444
- # servlet instance for every request and the DigestAuth object must be
445
- # used across requests.
446
- class WEBrick::HTTPAuth::DigestAuth
447
- include ::WEBrick::HTTPAuth::Authenticator
448
-
449
- # Creates a new DigestAuth instance. Be sure to use the same DigestAuth
450
- # instance for multiple requests as it saves state between requests in
451
- # order to perform authentication.
452
- #
453
- # See WEBrick::Config::DigestAuth for default configuration entries
454
- #
455
- # You must supply the following configuration entries:
456
- #
457
- # :Realm:: The name of the realm being protected.
458
- # :UserDB:: A database of usernames and passwords.
459
- # A WEBrick::HTTPAuth::Htdigest instance should be used.
460
- #
461
- # @return [DigestAuth] a new instance of DigestAuth
462
- def initialize(config, default = T.unsafe(nil)); end
463
-
464
- # Digest authentication algorithm
465
- def algorithm; end
466
-
467
- # Authenticates a +req+ and returns a 401 Unauthorized using +res+ if
468
- # the authentication was not correct.
469
- def authenticate(req, res); end
470
-
471
- # Returns a challenge response which asks for authentication information
472
- #
473
- # @raise [@auth_exception]
474
- def challenge(req, res, stale = T.unsafe(nil)); end
475
-
476
- # Quality of protection. RFC 2617 defines "auth" and "auth-int"
477
- def qop; end
478
-
479
- private
480
-
481
- def _authenticate(req, res); end
482
- def check_nonce(req, auth_req); end
483
- def check_opaque(opaque_struct, req, auth_req); end
484
- def check_uri(req, auth_req); end
485
- def generate_next_nonce(req); end
486
- def generate_opaque(req); end
487
- def hexdigest(*args); end
488
- def split_param_value(string); end
489
-
490
- class << self
491
- # Used by UserDB to create a digest password entry
492
- def make_passwd(realm, user, pass); end
493
- end
494
- end
495
-
496
- # Htdigest accesses apache-compatible digest password files. Passwords are
497
- # matched to a realm where they are valid. For security, the path for a
498
- # digest password database should be stored outside of the paths available
499
- # to the HTTP server.
500
- #
501
- # Htdigest is intended for use with WEBrick::HTTPAuth::DigestAuth and
502
- # stores passwords using cryptographic hashes.
503
- #
504
- # htpasswd = WEBrick::HTTPAuth::Htdigest.new 'my_password_file'
505
- # htpasswd.set_passwd 'my realm', 'username', 'password'
506
- # htpasswd.flush
507
- class WEBrick::HTTPAuth::Htdigest
508
- include ::WEBrick::HTTPAuth::UserDB
509
-
510
- # Open a digest password database at +path+
511
- #
512
- # @return [Htdigest] a new instance of Htdigest
513
- def initialize(path); end
514
-
515
- # Removes a password from the database for +user+ in +realm+.
516
- def delete_passwd(realm, user); end
517
-
518
- # Iterate passwords in the database.
519
- def each; end
520
-
521
- # Flush the password database. If +output+ is given the database will
522
- # be written there instead of to the original path.
523
- def flush(output = T.unsafe(nil)); end
524
-
525
- # Retrieves a password from the database for +user+ in +realm+. If
526
- # +reload_db+ is true the database will be reloaded first.
527
- def get_passwd(realm, user, reload_db); end
528
-
529
- # Reloads passwords from the database
530
- def reload; end
531
-
532
- # Sets a password in the database for +user+ in +realm+ to +pass+.
533
- def set_passwd(realm, user, pass); end
534
- end
535
-
536
- # Htgroup accesses apache-compatible group files. Htgroup can be used to
537
- # provide group-based authentication for users. Currently Htgroup is not
538
- # directly integrated with any authenticators in WEBrick. For security,
539
- # the path for a digest password database should be stored outside of the
540
- # paths available to the HTTP server.
541
- #
542
- # Example:
543
- #
544
- # htgroup = WEBrick::HTTPAuth::Htgroup.new 'my_group_file'
545
- # htgroup.add 'superheroes', %w[spiderman batman]
546
- #
547
- # htgroup.members('superheroes').include? 'magneto' # => false
548
- class WEBrick::HTTPAuth::Htgroup
549
- # Open a group database at +path+
550
- #
551
- # @return [Htgroup] a new instance of Htgroup
552
- def initialize(path); end
553
-
554
- # Add an Array of +members+ to +group+
555
- def add(group, members); end
556
-
557
- # Flush the group database. If +output+ is given the database will be
558
- # written there instead of to the original path.
559
- def flush(output = T.unsafe(nil)); end
560
-
561
- # Retrieve the list of members from +group+
562
- def members(group); end
563
-
564
- # Reload groups from the database
565
- def reload; end
566
- end
567
-
568
- # Htpasswd accesses apache-compatible password files. Passwords are
569
- # matched to a realm where they are valid. For security, the path for a
570
- # password database should be stored outside of the paths available to the
571
- # HTTP server.
572
- #
573
- # Htpasswd is intended for use with WEBrick::HTTPAuth::BasicAuth.
574
- #
575
- # To create an Htpasswd database with a single user:
576
- #
577
- # htpasswd = WEBrick::HTTPAuth::Htpasswd.new 'my_password_file'
578
- # htpasswd.set_passwd 'my realm', 'username', 'password'
579
- # htpasswd.flush
580
- class WEBrick::HTTPAuth::Htpasswd
581
- include ::WEBrick::HTTPAuth::UserDB
582
-
583
- # Open a password database at +path+
584
- #
585
- # @return [Htpasswd] a new instance of Htpasswd
586
- def initialize(path, password_hash: T.unsafe(nil)); end
587
-
588
- # Removes a password from the database for +user+ in +realm+.
589
- def delete_passwd(realm, user); end
590
-
591
- # Iterate passwords in the database.
592
- def each; end
593
-
594
- # Flush the password database. If +output+ is given the database will
595
- # be written there instead of to the original path.
596
- def flush(output = T.unsafe(nil)); end
597
-
598
- # Retrieves a password from the database for +user+ in +realm+. If
599
- # +reload_db+ is true the database will be reloaded first.
600
- def get_passwd(realm, user, reload_db); end
601
-
602
- # Reload passwords from the database
603
- def reload; end
604
-
605
- # Sets a password in the database for +user+ in +realm+ to +pass+.
606
- def set_passwd(realm, user, pass); end
607
- end
608
-
609
- WEBrick::HTTPAuth::ProxyAuthenticator::AuthException = WEBrick::HTTPStatus::ProxyAuthenticationRequired
610
-
611
- # Basic authentication for proxy servers. See BasicAuth for details.
612
- class WEBrick::HTTPAuth::ProxyBasicAuth < ::WEBrick::HTTPAuth::BasicAuth
613
- include ::WEBrick::HTTPAuth::ProxyAuthenticator
614
- end
615
-
616
- # Digest authentication for proxy servers. See DigestAuth for details.
617
- class WEBrick::HTTPAuth::ProxyDigestAuth < ::WEBrick::HTTPAuth::DigestAuth
618
- include ::WEBrick::HTTPAuth::ProxyAuthenticator
619
-
620
- private
621
-
622
- def check_uri(req, auth_req); end
623
- end
624
-
625
- # User database mixin for HTTPAuth. This mixin dispatches user record
626
- # access to the underlying auth_type for this database.
627
- module WEBrick::HTTPAuth::UserDB
628
- # The authentication type.
629
- #
630
- # WEBrick::HTTPAuth::BasicAuth or WEBrick::HTTPAuth::DigestAuth are
631
- # built-in.
632
- def auth_type; end
633
-
634
- # The authentication type.
635
- #
636
- # WEBrick::HTTPAuth::BasicAuth or WEBrick::HTTPAuth::DigestAuth are
637
- # built-in.
638
- def auth_type=(_arg0); end
639
-
640
- # Retrieves a password in +realm+ for +user+ for the auth_type of this
641
- # database. +reload_db+ is a dummy value.
642
- def get_passwd(realm, user, reload_db = T.unsafe(nil)); end
643
-
644
- # Creates an obscured password in +realm+ with +user+ and +password+
645
- # using the auth_type of this database.
646
- def make_passwd(realm, user, pass); end
647
-
648
- # Sets a password in +realm+ with +user+ and +password+ for the
649
- # auth_type of this database.
650
- def set_passwd(realm, user, pass); end
651
- end
652
-
653
- # --
654
- # Adds SSL functionality to WEBrick::HTTPRequest
655
- class WEBrick::HTTPRequest
656
- # Creates a new HTTP request. WEBrick::Config::HTTP is the default
657
- # configuration.
658
- #
659
- # @return [HTTPRequest] a new instance of HTTPRequest
660
- def initialize(config); end
661
-
662
- # Retrieves +header_name+
663
- def [](header_name); end
664
-
665
- # The Accept header value
666
- def accept; end
667
-
668
- # The Accept-Charset header value
669
- def accept_charset; end
670
-
671
- # The Accept-Encoding header value
672
- def accept_encoding; end
673
-
674
- # The Accept-Language header value
675
- def accept_language; end
676
-
677
- # The socket address of the server
678
- def addr; end
679
-
680
- # Hash of request attributes
681
- def attributes; end
682
-
683
- # Returns the request body.
684
- def body(&block); end
685
-
686
- # Prepares the HTTPRequest object for use as the
687
- # source for IO.copy_stream
688
- def body_reader; end
689
-
690
- # The content-length header
691
- def content_length; end
692
-
693
- # The content-type header
694
- def content_type; end
695
-
696
- # Generate HTTP/1.1 100 continue response if the client expects it,
697
- # otherwise does nothing.
698
- def continue; end
699
-
700
- # The parsed request cookies
701
- def cookies; end
702
-
703
- # Iterates over the request headers
704
- def each; end
705
-
706
- # Consumes any remaining body and updates keep-alive status
707
- def fixup; end
708
-
709
- # The parsed header of the request
710
- def header; end
711
-
712
- # The host this request is for
713
- def host; end
714
-
715
- # The HTTP version of the request
716
- def http_version; end
717
-
718
- # Is this a keep-alive connection?
719
- def keep_alive; end
720
-
721
- # Should the connection this request was made on be kept alive?
722
- #
723
- # @return [Boolean]
724
- def keep_alive?; end
725
-
726
- # This method provides the metavariables defined by the revision 3
727
- # of "The WWW Common Gateway Interface Version 1.1"
728
- # To browse the current document of CGI Version 1.1, see below:
729
- # http://tools.ietf.org/html/rfc3875
730
- def meta_vars; end
731
-
732
- # Parses a request from +socket+. This is called internally by
733
- # WEBrick::HTTPServer.
734
- def parse(socket = T.unsafe(nil)); end
735
-
736
- # The request path
737
- def path; end
738
-
739
- # The path info (CGI variable)
740
- def path_info; end
741
-
742
- # The path info (CGI variable)
743
- def path_info=(_arg0); end
744
-
745
- # The socket address of the client
746
- def peeraddr; end
747
-
748
- # The port this request is for
749
- def port; end
750
-
751
- # Request query as a Hash
752
- def query; end
753
-
754
- # The query from the URI of the request
755
- def query_string; end
756
-
757
- # The query from the URI of the request
758
- def query_string=(_arg0); end
759
-
760
- # The raw header of the request
761
- def raw_header; end
762
-
763
- # for IO.copy_stream.
764
- def readpartial(size, buf = T.unsafe(nil)); end
765
-
766
- # The client's IP address
767
- def remote_ip; end
768
-
769
- # The complete request line such as:
770
- #
771
- # GET / HTTP/1.1
772
- def request_line; end
773
-
774
- # The request method, GET, POST, PUT, etc.
775
- def request_method; end
776
-
777
- # The local time this request was received
778
- def request_time; end
779
-
780
- # The parsed URI of the request
781
- def request_uri; end
782
-
783
- # The script name (CGI variable)
784
- def script_name; end
785
-
786
- # The script name (CGI variable)
787
- def script_name=(_arg0); end
788
-
789
- # The server name this request is for
790
- def server_name; end
791
-
792
- # Is this an SSL request?
793
- #
794
- # @return [Boolean]
795
- def ssl?; end
796
-
797
- def to_s; end
798
-
799
- # The unparsed URI of the request
800
- def unparsed_uri; end
801
-
802
- # The remote user (CGI variable)
803
- def user; end
804
-
805
- # The remote user (CGI variable)
806
- def user=(_arg0); end
807
-
808
- private
809
-
810
- def _read_data(io, method, *arg); end
811
- def parse_query; end
812
- def parse_uri(str, scheme = T.unsafe(nil)); end
813
- def read_body(socket, block); end
814
- def read_chunk_size(socket); end
815
- def read_chunked(socket, block); end
816
- def read_data(io, size); end
817
- def read_header(socket); end
818
- def read_line(io, size = T.unsafe(nil)); end
819
-
820
- # @raise [HTTPStatus::EOFError]
821
- def read_request_line(socket); end
822
-
823
- # It's said that all X-Forwarded-* headers will contain more than one
824
- # (comma-separated) value if the original request already contained one of
825
- # these headers. Since we could use these values as Host header, we choose
826
- # the initial(first) value. (apr_table_mergen() adds new value after the
827
- # existing value with ", " prefix)
828
- def setup_forwarded_info; end
829
- end
830
-
831
- # same as Mongrel, Thin and Puma
832
- WEBrick::HTTPRequest::MAX_HEADER_LENGTH = T.let(T.unsafe(nil), Integer)
833
-
834
- # An HTTP response. This is filled in by the service or do_* methods of a
835
- # WEBrick HTTP Servlet.
836
- class WEBrick::HTTPResponse
837
- # Creates a new HTTP response object. WEBrick::Config::HTTP is the
838
- # default configuration.
839
- #
840
- # @return [HTTPResponse] a new instance of HTTPResponse
841
- def initialize(config); end
842
-
843
- # Retrieves the response header +field+
844
- def [](field); end
845
-
846
- # Sets the response header +field+ to +value+
847
- def []=(field, value); end
848
-
849
- # Body may be:
850
- # * a String;
851
- # * an IO-like object that responds to +#read+ and +#readpartial+;
852
- # * a Proc-like object that responds to +#call+.
853
- #
854
- # In the latter case, either #chunked= should be set to +true+,
855
- # or <code>header['content-length']</code> explicitly provided.
856
- # Example:
857
- #
858
- # server.mount_proc '/' do |req, res|
859
- # res.chunked = true
860
- # # or
861
- # # res.header['content-length'] = 10
862
- # res.body = proc { |out| out.write(Time.now.to_s) }
863
- # end
864
- def body; end
865
-
866
- # Body may be:
867
- # * a String;
868
- # * an IO-like object that responds to +#read+ and +#readpartial+;
869
- # * a Proc-like object that responds to +#call+.
870
- #
871
- # In the latter case, either #chunked= should be set to +true+,
872
- # or <code>header['content-length']</code> explicitly provided.
873
- # Example:
874
- #
875
- # server.mount_proc '/' do |req, res|
876
- # res.chunked = true
877
- # # or
878
- # # res.header['content-length'] = 10
879
- # res.body = proc { |out| out.write(Time.now.to_s) }
880
- # end
881
- def body=(_arg0); end
882
-
883
- # Enables chunked transfer encoding.
884
- def chunked=(val); end
885
-
886
- # Will this response body be returned using chunked transfer-encoding?
887
- #
888
- # @return [Boolean]
889
- def chunked?; end
890
-
891
- # Configuration for this response
892
- def config; end
893
-
894
- # The content-length header
895
- def content_length; end
896
-
897
- # Sets the content-length header to +len+
898
- def content_length=(len); end
899
-
900
- # The content-type header
901
- def content_type; end
902
-
903
- # Sets the content-type header to +type+
904
- def content_type=(type); end
905
-
906
- # Response cookies
907
- def cookies; end
908
-
909
- # Iterates over each header in the response
910
- def each; end
911
-
912
- # Filename of the static file in this response. Only used by the
913
- # FileHandler servlet.
914
- def filename; end
915
-
916
- # Filename of the static file in this response. Only used by the
917
- # FileHandler servlet.
918
- def filename=(_arg0); end
919
-
920
- # Response header
921
- def header; end
922
-
923
- # HTTP Response version
924
- def http_version; end
925
-
926
- # Is this a keep-alive response?
927
- def keep_alive; end
928
-
929
- # Is this a keep-alive response?
930
- def keep_alive=(_arg0); end
931
-
932
- # Will this response's connection be kept alive?
933
- #
934
- # @return [Boolean]
935
- def keep_alive?; end
936
-
937
- def make_body_tempfile; end
938
-
939
- # Response reason phrase ("OK")
940
- def reason_phrase; end
941
-
942
- # Response reason phrase ("OK")
943
- def reason_phrase=(_arg0); end
944
-
945
- def remove_body_tempfile; end
946
-
947
- # Request HTTP version for this response
948
- def request_http_version; end
949
-
950
- # Request HTTP version for this response
951
- def request_http_version=(_arg0); end
952
-
953
- # Request method for this response
954
- def request_method; end
955
-
956
- # Request method for this response
957
- def request_method=(_arg0); end
958
-
959
- # Request URI for this response
960
- def request_uri; end
961
-
962
- # Request URI for this response
963
- def request_uri=(_arg0); end
964
-
965
- # Sends the body on +socket+
966
- def send_body(socket); end
967
-
968
- # Sends the headers on +socket+
969
- def send_header(socket); end
970
-
971
- # Sends the response on +socket+
972
- def send_response(socket); end
973
-
974
- # Bytes sent in this response
975
- def sent_size; end
976
-
977
- # Creates an error page for exception +ex+ with an optional +backtrace+
978
- def set_error(ex, backtrace = T.unsafe(nil)); end
979
-
980
- # Redirects to +url+ with a WEBrick::HTTPStatus::Redirect +status+.
981
- #
982
- # Example:
983
- #
984
- # res.set_redirect WEBrick::HTTPStatus::TemporaryRedirect
985
- def set_redirect(status, url); end
986
-
987
- # Sets up the headers for sending
988
- def setup_header; end
989
-
990
- # Response status code (200)
991
- def status; end
992
-
993
- # Sets the response's status to the +status+ code
994
- def status=(status); end
995
-
996
- # The response's HTTP status line
997
- def status_line; end
998
-
999
- private
1000
-
1001
- # preserved for compatibility with some 3rd-party handlers
1002
- def _write_data(socket, data); end
1003
-
1004
- def check_header(header_value); end
1005
-
1006
- # :stopdoc:
1007
- def error_body(backtrace, ex, host, port); end
1008
-
1009
- def send_body_io(socket); end
1010
- def send_body_proc(socket); end
1011
- def send_body_string(socket); end
1012
- end
1013
-
1014
- class WEBrick::HTTPResponse::ChunkedWrapper
1015
- # @return [ChunkedWrapper] a new instance of ChunkedWrapper
1016
- def initialize(socket, resp); end
1017
-
1018
- def <<(*buf); end
1019
- def write(buf); end
1020
- end
1021
-
1022
- # An HTTP Server
1023
- class WEBrick::HTTPServer < ::WEBrick::GenericServer
1024
- # Creates a new HTTP server according to +config+
1025
- #
1026
- # An HTTP server uses the following attributes:
1027
- #
1028
- # :AccessLog:: An array of access logs. See WEBrick::AccessLog
1029
- # :BindAddress:: Local address for the server to bind to
1030
- # :DocumentRoot:: Root path to serve files from
1031
- # :DocumentRootOptions:: Options for the default HTTPServlet::FileHandler
1032
- # :HTTPVersion:: The HTTP version of this server
1033
- # :Port:: Port to listen on
1034
- # :RequestCallback:: Called with a request and response before each
1035
- # request is serviced.
1036
- # :RequestTimeout:: Maximum time to wait between requests
1037
- # :ServerAlias:: Array of alternate names for this server for virtual
1038
- # hosting
1039
- # :ServerName:: Name for this server for virtual hosting
1040
- #
1041
- # @return [HTTPServer] a new instance of HTTPServer
1042
- def initialize(config = T.unsafe(nil), default = T.unsafe(nil)); end
1043
-
1044
- # Logs +req+ and +res+ in the access logs. +config+ is used for the
1045
- # server name.
1046
- def access_log(config, req, res); end
1047
-
1048
- # Creates the HTTPRequest used when handling the HTTP
1049
- # request. Can be overridden by subclasses.
1050
- def create_request(with_webrick_config); end
1051
-
1052
- # Creates the HTTPResponse used when handling the HTTP
1053
- # request. Can be overridden by subclasses.
1054
- def create_response(with_webrick_config); end
1055
-
1056
- # The default OPTIONS request handler says GET, HEAD, POST and OPTIONS
1057
- # requests are allowed.
1058
- def do_OPTIONS(req, res); end
1059
-
1060
- # Finds the appropriate virtual host to handle +req+
1061
- def lookup_server(req); end
1062
-
1063
- # Mounts +servlet+ on +dir+ passing +options+ to the servlet at creation
1064
- # time
1065
- def mount(dir, servlet, *options); end
1066
-
1067
- # Mounts +proc+ or +block+ on +dir+ and calls it with a
1068
- # WEBrick::HTTPRequest and WEBrick::HTTPResponse
1069
- #
1070
- # @raise [HTTPServerError]
1071
- def mount_proc(dir, proc = T.unsafe(nil), &block); end
1072
-
1073
- # Processes requests on +sock+
1074
- def run(sock); end
1075
-
1076
- # Finds a servlet for +path+
1077
- def search_servlet(path); end
1078
-
1079
- # Services +req+ and fills in +res+
1080
- #
1081
- # @raise [HTTPStatus::NotFound]
1082
- def service(req, res); end
1083
-
1084
- # Unmounts +dir+
1085
- def umount(dir); end
1086
-
1087
- # Unmounts +dir+
1088
- def unmount(dir); end
1089
-
1090
- # Adds +server+ as a virtual host.
1091
- def virtual_host(server); end
1092
- end
1093
-
1094
- # Mount table for the path a servlet is mounted on in the directory space
1095
- # of the server. Users of WEBrick can only access this indirectly via
1096
- # WEBrick::HTTPServer#mount, WEBrick::HTTPServer#unmount and
1097
- # WEBrick::HTTPServer#search_servlet
1098
- class WEBrick::HTTPServer::MountTable
1099
- # @return [MountTable] a new instance of MountTable
1100
- def initialize; end
1101
-
1102
- def [](dir); end
1103
- def []=(dir, val); end
1104
- def delete(dir); end
1105
- def scan(path); end
1106
-
1107
- private
1108
-
1109
- def compile; end
1110
- def normalize(dir); end
1111
- end
1112
-
1113
- # AbstractServlet allows HTTP server modules to be reused across multiple
1114
- # servers and allows encapsulation of functionality.
1115
- #
1116
- # By default a servlet will respond to GET, HEAD (through an alias to GET)
1117
- # and OPTIONS requests.
1118
- #
1119
- # By default a new servlet is initialized for every request. A servlet
1120
- # instance can be reused by overriding ::get_instance in the
1121
- # AbstractServlet subclass.
1122
- #
1123
- # == A Simple Servlet
1124
- #
1125
- # class Simple < WEBrick::HTTPServlet::AbstractServlet
1126
- # def do_GET request, response
1127
- # status, content_type, body = do_stuff_with request
1128
- #
1129
- # response.status = status
1130
- # response['Content-Type'] = content_type
1131
- # response.body = body
1132
- # end
1133
- #
1134
- # def do_stuff_with request
1135
- # return 200, 'text/plain', 'you got a page'
1136
- # end
1137
- # end
1138
- #
1139
- # This servlet can be mounted on a server at a given path:
1140
- #
1141
- # server.mount '/simple', Simple
1142
- #
1143
- # == Servlet Configuration
1144
- #
1145
- # Servlets can be configured via initialize. The first argument is the
1146
- # HTTP server the servlet is being initialized for.
1147
- #
1148
- # class Configurable < Simple
1149
- # def initialize server, color, size
1150
- # super server
1151
- # @color = color
1152
- # @size = size
1153
- # end
1154
- #
1155
- # def do_stuff_with request
1156
- # content = "<p " \
1157
- # %q{style="color: #{@color}; font-size: #{@size}"} \
1158
- # ">Hello, World!"
1159
- #
1160
- # return 200, "text/html", content
1161
- # end
1162
- # end
1163
- #
1164
- # This servlet must be provided two arguments at mount time:
1165
- #
1166
- # server.mount '/configurable', Configurable, 'red', '2em'
1167
- class WEBrick::HTTPServlet::AbstractServlet
1168
- # Initializes a new servlet for +server+ using +options+ which are
1169
- # stored as-is in +@options+. +@logger+ is also provided.
1170
- #
1171
- # @return [AbstractServlet] a new instance of AbstractServlet
1172
- def initialize(server, *options); end
1173
-
1174
- # Raises a NotFound exception
1175
- #
1176
- # @raise [HTTPStatus::NotFound]
1177
- def do_GET(req, res); end
1178
-
1179
- # Dispatches to do_GET
1180
- def do_HEAD(req, res); end
1181
-
1182
- # Returns the allowed HTTP request methods
1183
- def do_OPTIONS(req, res); end
1184
-
1185
- # Dispatches to a +do_+ method based on +req+ if such a method is
1186
- # available. (+do_GET+ for a GET request). Raises a MethodNotAllowed
1187
- # exception if the method is not implemented.
1188
- def service(req, res); end
1189
-
1190
- private
1191
-
1192
- # Redirects to a path ending in /
1193
- def redirect_to_directory_uri(req, res); end
1194
-
1195
- class << self
1196
- # Factory for servlet instances that will handle a request from +server+
1197
- # using +options+ from the mount point. By default a new servlet
1198
- # instance is created for every call.
1199
- def get_instance(server, *options); end
1200
- end
1201
- end
1202
-
1203
- # Servlet for handling CGI scripts
1204
- #
1205
- # Example:
1206
- #
1207
- # server.mount('/cgi/my_script', WEBrick::HTTPServlet::CGIHandler,
1208
- # '/path/to/my_script')
1209
- class WEBrick::HTTPServlet::CGIHandler < ::WEBrick::HTTPServlet::AbstractServlet
1210
- # Creates a new CGI script servlet for the script at +name+
1211
- #
1212
- # @return [CGIHandler] a new instance of CGIHandler
1213
- def initialize(server, name); end
1214
-
1215
- # :stopdoc:
1216
- #
1217
- # @raise [HTTPStatus::InternalServerError]
1218
- def do_GET(req, res); end
1219
-
1220
- # :stopdoc:
1221
- #
1222
- # @raise [HTTPStatus::InternalServerError]
1223
- def do_POST(req, res); end
1224
- end
1225
-
1226
- WEBrick::HTTPServlet::CGIHandler::CGIRunnerArray = T.let(T.unsafe(nil), Array)
1227
-
1228
- # Servlet for serving a single file. You probably want to use the
1229
- # FileHandler servlet instead as it handles directories and fancy indexes.
1230
- #
1231
- # Example:
1232
- #
1233
- # server.mount('/my_page.txt', WEBrick::HTTPServlet::DefaultFileHandler,
1234
- # '/path/to/my_page.txt')
1235
- #
1236
- # This servlet handles If-Modified-Since and Range requests.
1237
- class WEBrick::HTTPServlet::DefaultFileHandler < ::WEBrick::HTTPServlet::AbstractServlet
1238
- # Creates a DefaultFileHandler instance for the file at +local_path+.
1239
- #
1240
- # @return [DefaultFileHandler] a new instance of DefaultFileHandler
1241
- def initialize(server, local_path); end
1242
-
1243
- # :stopdoc:
1244
- def do_GET(req, res); end
1245
-
1246
- def make_partial_content(req, res, filename, filesize); end
1247
-
1248
- # returns a lambda for webrick/httpresponse.rb send_body_proc
1249
- def multipart_body(body, parts, boundary, mtype, filesize); end
1250
-
1251
- # @return [Boolean]
1252
- def not_modified?(req, res, mtime, etag); end
1253
-
1254
- def prepare_range(range, filesize); end
1255
- end
1256
-
1257
- # ERBHandler evaluates an ERB file and returns the result. This handler
1258
- # is automatically used if there are .rhtml files in a directory served by
1259
- # the FileHandler.
1260
- #
1261
- # ERBHandler supports GET and POST methods.
1262
- #
1263
- # The ERB file is evaluated with the local variables +servlet_request+ and
1264
- # +servlet_response+ which are a WEBrick::HTTPRequest and
1265
- # WEBrick::HTTPResponse respectively.
1266
- #
1267
- # Example .rhtml file:
1268
- #
1269
- # Request to <%= servlet_request.request_uri %>
1270
- #
1271
- # Query params <%= servlet_request.query.inspect %>
1272
- class WEBrick::HTTPServlet::ERBHandler < ::WEBrick::HTTPServlet::AbstractServlet
1273
- # Creates a new ERBHandler on +server+ that will evaluate and serve the
1274
- # ERB file +name+
1275
- #
1276
- # @return [ERBHandler] a new instance of ERBHandler
1277
- def initialize(server, name); end
1278
-
1279
- # Handles GET requests
1280
- def do_GET(req, res); end
1281
-
1282
- # Handles GET requests
1283
- #
1284
- # Handles POST requests
1285
- def do_POST(req, res); end
1286
-
1287
- private
1288
-
1289
- # Evaluates +erb+ providing +servlet_request+ and +servlet_response+ as
1290
- # local variables.
1291
- def evaluate(erb, servlet_request, servlet_response); end
1292
- end
1293
-
1294
- # Serves a directory including fancy indexing and a variety of other
1295
- # options.
1296
- #
1297
- # Example:
1298
- #
1299
- # server.mount('/assets', WEBrick::HTTPServlet::FileHandler,
1300
- # '/path/to/assets')
1301
- class WEBrick::HTTPServlet::FileHandler < ::WEBrick::HTTPServlet::AbstractServlet
1302
- # Creates a FileHandler servlet on +server+ that serves files starting
1303
- # at directory +root+
1304
- #
1305
- # +options+ may be a Hash containing keys from
1306
- # WEBrick::Config::FileHandler or +true+ or +false+.
1307
- #
1308
- # If +options+ is true or false then +:FancyIndexing+ is enabled or
1309
- # disabled respectively.
1310
- #
1311
- # @return [FileHandler] a new instance of FileHandler
1312
- def initialize(server, root, options = T.unsafe(nil), default = T.unsafe(nil)); end
1313
-
1314
- def do_GET(req, res); end
1315
- def do_OPTIONS(req, res); end
1316
- def do_POST(req, res); end
1317
- def service(req, res); end
1318
-
1319
- # :stopdoc:
1320
- def set_filesystem_encoding(str); end
1321
-
1322
- private
1323
-
1324
- def call_callback(callback_name, req, res); end
1325
- def check_filename(req, res, name); end
1326
-
1327
- # @raise [HTTPStatus::NotFound]
1328
- def exec_handler(req, res); end
1329
-
1330
- def get_handler(req, res); end
1331
-
1332
- # @return [Boolean]
1333
- def nondisclosure_name?(name); end
1334
-
1335
- def prevent_directory_traversal(req, res); end
1336
- def search_file(req, res, basename); end
1337
- def search_index_file(req, res); end
1338
- def set_dir_list(req, res); end
1339
- def set_filename(req, res); end
1340
- def shift_path_info(req, res, path_info, base = T.unsafe(nil)); end
1341
-
1342
- # @return [Boolean]
1343
- def trailing_pathsep?(path); end
1344
-
1345
- # @return [Boolean]
1346
- def windows_ambiguous_name?(name); end
1347
-
1348
- class << self
1349
- # Allow custom handling of requests for files with +suffix+ by class
1350
- # +handler+
1351
- def add_handler(suffix, handler); end
1352
-
1353
- # Remove custom handling of requests for files with +suffix+
1354
- def remove_handler(suffix); end
1355
- end
1356
- end
1357
-
1358
- # This module is used to manager HTTP status codes.
1359
- #
1360
- # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more
1361
- # information.
1362
- module WEBrick::HTTPStatus
1363
- private
1364
-
1365
- # Is +code+ a client error status?
1366
- #
1367
- # @return [Boolean]
1368
- def client_error?(code); end
1369
-
1370
- # Is +code+ an error status?
1371
- #
1372
- # @return [Boolean]
1373
- def error?(code); end
1374
-
1375
- # Is +code+ an informational status?
1376
- #
1377
- # @return [Boolean]
1378
- def info?(code); end
1379
-
1380
- # Returns the description corresponding to the HTTP status +code+
1381
- #
1382
- # WEBrick::HTTPStatus.reason_phrase 404
1383
- # => "Not Found"
1384
- def reason_phrase(code); end
1385
-
1386
- # Is +code+ a redirection status?
1387
- #
1388
- # @return [Boolean]
1389
- def redirect?(code); end
1390
-
1391
- # Is +code+ a server error status?
1392
- #
1393
- # @return [Boolean]
1394
- def server_error?(code); end
1395
-
1396
- # Is +code+ a successful status?
1397
- #
1398
- # @return [Boolean]
1399
- def success?(code); end
1400
-
1401
- class << self
1402
- # Returns the status class corresponding to +code+
1403
- #
1404
- # WEBrick::HTTPStatus[302]
1405
- # => WEBrick::HTTPStatus::NotFound
1406
- def [](code); end
1407
-
1408
- # Is +code+ a client error status?
1409
- #
1410
- # @return [Boolean]
1411
- def client_error?(code); end
1412
-
1413
- # Is +code+ an error status?
1414
- #
1415
- # @return [Boolean]
1416
- def error?(code); end
1417
-
1418
- # Is +code+ an informational status?
1419
- #
1420
- # @return [Boolean]
1421
- def info?(code); end
1422
-
1423
- # Returns the description corresponding to the HTTP status +code+
1424
- #
1425
- # WEBrick::HTTPStatus.reason_phrase 404
1426
- # => "Not Found"
1427
- def reason_phrase(code); end
1428
-
1429
- # Is +code+ a redirection status?
1430
- #
1431
- # @return [Boolean]
1432
- def redirect?(code); end
1433
-
1434
- # Is +code+ a server error status?
1435
- #
1436
- # @return [Boolean]
1437
- def server_error?(code); end
1438
-
1439
- # Is +code+ a successful status?
1440
- #
1441
- # @return [Boolean]
1442
- def success?(code); end
1443
- end
1444
- end
1445
-
1446
- # Root of the HTTP status class hierarchy
1447
- class WEBrick::HTTPStatus::Status < ::StandardError
1448
- # Returns the HTTP status code
1449
- def code; end
1450
-
1451
- # Returns the HTTP status description
1452
- def reason_phrase; end
1453
-
1454
- # Returns the HTTP status code
1455
- def to_i; end
1456
-
1457
- class << self
1458
- def code; end
1459
- def reason_phrase; end
1460
- end
1461
- end
1462
-
1463
- # HTTPUtils provides utility methods for working with the HTTP protocol.
1464
- #
1465
- # This module is generally used internally by WEBrick
1466
- module WEBrick::HTTPUtils
1467
- private
1468
-
1469
- def _escape(str, regex); end
1470
-
1471
- # :stopdoc:
1472
- def _make_regex(str); end
1473
-
1474
- def _make_regex!(str); end
1475
- def _unescape(str, regex); end
1476
-
1477
- # Removes quotes and escapes from +str+
1478
- def dequote(str); end
1479
-
1480
- # Escapes HTTP reserved and unwise characters in +str+
1481
- def escape(str); end
1482
-
1483
- # Escapes 8 bit characters in +str+
1484
- def escape8bit(str); end
1485
-
1486
- # Escapes form reserved characters in +str+
1487
- def escape_form(str); end
1488
-
1489
- # Escapes path +str+
1490
- def escape_path(str); end
1491
-
1492
- # Loads Apache-compatible mime.types in +file+.
1493
- def load_mime_types(file); end
1494
-
1495
- # Returns the mime type of +filename+ from the list in +mime_tab+. If no
1496
- # mime type was found application/octet-stream is returned.
1497
- def mime_type(filename, mime_tab); end
1498
-
1499
- # Normalizes a request path. Raises an exception if the path cannot be
1500
- # normalized.
1501
- def normalize_path(path); end
1502
-
1503
- # Parses form data in +io+ with the given +boundary+
1504
- def parse_form_data(io, boundary); end
1505
-
1506
- # Parses an HTTP header +raw+ into a hash of header fields with an Array
1507
- # of values.
1508
- def parse_header(raw); end
1509
-
1510
- # Parses the query component of a URI in +str+
1511
- def parse_query(str); end
1512
-
1513
- # Parses q values in +value+ as used in Accept headers.
1514
- def parse_qvalues(value); end
1515
-
1516
- # Parses a Range header value +ranges_specifier+
1517
- def parse_range_header(ranges_specifier); end
1518
-
1519
- # Quotes and escapes quotes in +str+
1520
- def quote(str); end
1521
-
1522
- # Splits a header value +str+ according to HTTP specification.
1523
- def split_header_value(str); end
1524
-
1525
- # Unescapes HTTP reserved and unwise characters in +str+
1526
- def unescape(str); end
1527
-
1528
- # Unescapes form reserved characters in +str+
1529
- def unescape_form(str); end
1530
-
1531
- class << self
1532
- def _escape(str, regex); end
1533
-
1534
- # :stopdoc:
1535
- def _make_regex(str); end
1536
-
1537
- def _make_regex!(str); end
1538
- def _unescape(str, regex); end
1539
-
1540
- # Removes quotes and escapes from +str+
1541
- def dequote(str); end
1542
-
1543
- # Escapes HTTP reserved and unwise characters in +str+
1544
- def escape(str); end
1545
-
1546
- # Escapes 8 bit characters in +str+
1547
- def escape8bit(str); end
1548
-
1549
- # Escapes form reserved characters in +str+
1550
- def escape_form(str); end
1551
-
1552
- # Escapes path +str+
1553
- def escape_path(str); end
1554
-
1555
- # Loads Apache-compatible mime.types in +file+.
1556
- def load_mime_types(file); end
1557
-
1558
- # Returns the mime type of +filename+ from the list in +mime_tab+. If no
1559
- # mime type was found application/octet-stream is returned.
1560
- def mime_type(filename, mime_tab); end
1561
-
1562
- # Normalizes a request path. Raises an exception if the path cannot be
1563
- # normalized.
1564
- def normalize_path(path); end
1565
-
1566
- # Parses form data in +io+ with the given +boundary+
1567
- def parse_form_data(io, boundary); end
1568
-
1569
- # Parses an HTTP header +raw+ into a hash of header fields with an Array
1570
- # of values.
1571
- def parse_header(raw); end
1572
-
1573
- # Parses the query component of a URI in +str+
1574
- def parse_query(str); end
1575
-
1576
- # Parses q values in +value+ as used in Accept headers.
1577
- def parse_qvalues(value); end
1578
-
1579
- # Parses a Range header value +ranges_specifier+
1580
- def parse_range_header(ranges_specifier); end
1581
-
1582
- # Quotes and escapes quotes in +str+
1583
- def quote(str); end
1584
-
1585
- # Splits a header value +str+ according to HTTP specification.
1586
- def split_header_value(str); end
1587
-
1588
- # Unescapes HTTP reserved and unwise characters in +str+
1589
- def unescape(str); end
1590
-
1591
- # Unescapes form reserved characters in +str+
1592
- def unescape_form(str); end
1593
- end
1594
- end
1595
-
1596
- # Stores multipart form data. FormData objects are created when
1597
- # WEBrick::HTTPUtils.parse_form_data is called.
1598
- class WEBrick::HTTPUtils::FormData < ::String
1599
- # Creates a new FormData object.
1600
- #
1601
- # +args+ is an Array of form data entries. One FormData will be created
1602
- # for each entry.
1603
- #
1604
- # This is called by WEBrick::HTTPUtils.parse_form_data for you
1605
- #
1606
- # @return [FormData] a new instance of FormData
1607
- def initialize(*args); end
1608
-
1609
- # Adds +str+ to this FormData which may be the body, a header or a
1610
- # header entry.
1611
- #
1612
- # This is called by WEBrick::HTTPUtils.parse_form_data for you
1613
- def <<(str); end
1614
-
1615
- # Retrieves the header at the first entry in +key+
1616
- def [](*key); end
1617
-
1618
- # Adds +data+ at the end of the chain of entries
1619
- #
1620
- # This is called by WEBrick::HTTPUtils.parse_form_data for you.
1621
- def append_data(data); end
1622
-
1623
- # Yields each entry in this FormData
1624
- def each_data; end
1625
-
1626
- # The filename of the form data part
1627
- def filename; end
1628
-
1629
- # The filename of the form data part
1630
- def filename=(_arg0); end
1631
-
1632
- # Returns all the FormData as an Array
1633
- def list; end
1634
-
1635
- # The name of the form data part
1636
- def name; end
1637
-
1638
- # The name of the form data part
1639
- def name=(_arg0); end
1640
-
1641
- def next_data=(_arg0); end
1642
-
1643
- # Returns all the FormData as an Array
1644
- #
1645
- # A FormData will behave like an Array
1646
- def to_ary; end
1647
-
1648
- # This FormData's body
1649
- def to_s; end
1650
-
1651
- protected
1652
-
1653
- def next_data; end
1654
- end
1655
-
1656
- module WEBrick::Utils
1657
- private
1658
-
1659
- # Creates TCP server sockets bound to +address+:+port+ and returns them.
1660
- #
1661
- # It will create IPV4 and IPV6 sockets on all interfaces.
1662
- def create_listeners(address, port); end
1663
-
1664
- # The server hostname
1665
- def getservername; end
1666
-
1667
- # Generates a random string of length +len+
1668
- def random_string(len); end
1669
-
1670
- # Sets the close on exec flag for +io+
1671
- def set_close_on_exec(io); end
1672
-
1673
- # Sets IO operations on +io+ to be non-blocking
1674
- def set_non_blocking(io); end
1675
-
1676
- # Changes the process's uid and gid to the ones of +user+
1677
- def su(user); end
1678
-
1679
- # Executes the passed block and raises +exception+ if execution takes more
1680
- # than +seconds+.
1681
- #
1682
- # If +seconds+ is zero or nil, simply executes the block
1683
- def timeout(seconds, exception = T.unsafe(nil)); end
1684
-
1685
- class << self
1686
- # Creates TCP server sockets bound to +address+:+port+ and returns them.
1687
- #
1688
- # It will create IPV4 and IPV6 sockets on all interfaces.
1689
- def create_listeners(address, port); end
1690
-
1691
- # The server hostname
1692
- def getservername; end
1693
-
1694
- # Generates a random string of length +len+
1695
- def random_string(len); end
1696
-
1697
- # Sets the close on exec flag for +io+
1698
- def set_close_on_exec(io); end
1699
-
1700
- # Sets IO operations on +io+ to be non-blocking
1701
- def set_non_blocking(io); end
1702
-
1703
- # Changes the process's uid and gid to the ones of +user+
1704
- def su(user); end
1705
-
1706
- # Executes the passed block and raises +exception+ if execution takes more
1707
- # than +seconds+.
1708
- #
1709
- # If +seconds+ is zero or nil, simply executes the block
1710
- def timeout(seconds, exception = T.unsafe(nil)); end
1711
- end
1712
- end
1713
-
1714
- # Class used to manage timeout handlers across multiple threads.
1715
- #
1716
- # Timeout handlers should be managed by using the class methods which are
1717
- # synchronized.
1718
- #
1719
- # id = TimeoutHandler.register(10, Timeout::Error)
1720
- # begin
1721
- # sleep 20
1722
- # puts 'foo'
1723
- # ensure
1724
- # TimeoutHandler.cancel(id)
1725
- # end
1726
- #
1727
- # will raise Timeout::Error
1728
- #
1729
- # id = TimeoutHandler.register(10, Timeout::Error)
1730
- # begin
1731
- # sleep 5
1732
- # puts 'foo'
1733
- # ensure
1734
- # TimeoutHandler.cancel(id)
1735
- # end
1736
- #
1737
- # will print 'foo'
1738
- class WEBrick::Utils::TimeoutHandler
1739
- include ::Singleton
1740
- extend ::Singleton::SingletonClassMethods
1741
-
1742
- # Creates a new TimeoutHandler. You should use ::register and ::cancel
1743
- # instead of creating the timeout handler directly.
1744
- #
1745
- # @return [TimeoutHandler] a new instance of TimeoutHandler
1746
- def initialize; end
1747
-
1748
- # Cancels the timeout handler +id+
1749
- def cancel(thread, id); end
1750
-
1751
- # Interrupts the timeout handler +id+ and raises +exception+
1752
- def interrupt(thread, id, exception); end
1753
-
1754
- # Registers a new timeout handler
1755
- #
1756
- # +time+:: Timeout in seconds
1757
- # +exception+:: Exception to raise when timeout elapsed
1758
- def register(thread, time, exception); end
1759
-
1760
- def terminate; end
1761
-
1762
- private
1763
-
1764
- def watch; end
1765
- def watcher; end
1766
-
1767
- class << self
1768
- # Cancels the timeout handler +id+
1769
- def cancel(id); end
1770
-
1771
- # Registers a new timeout handler
1772
- #
1773
- # +time+:: Timeout in seconds
1774
- # +exception+:: Exception to raise when timeout elapsed
1775
- def register(seconds, exception); end
1776
-
1777
- def terminate; end
1778
- end
1779
- end