webrick 1.8.2 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/README.md +2 -0
- data/lib/webrick/cgi.rb +1 -1
- data/lib/webrick/httpauth/authenticator.rb +4 -4
- data/lib/webrick/httpauth/htgroup.rb +1 -1
- data/lib/webrick/httpauth/htpasswd.rb +2 -2
- data/lib/webrick/httpproxy.rb +4 -4
- data/lib/webrick/httprequest.rb +6 -6
- data/lib/webrick/httpresponse.rb +1 -1
- data/lib/webrick/httpserver.rb +2 -2
- data/lib/webrick/httpservlet/abstract.rb +1 -1
- data/lib/webrick/httpservlet/filehandler.rb +6 -6
- data/lib/webrick/httputils.rb +2 -2
- data/lib/webrick/server.rb +1 -1
- data/lib/webrick/version.rb +1 -1
- data/sig/accesslog.rbs +24 -0
- data/sig/cgi.rbs +92 -0
- data/sig/compat.rbs +18 -0
- data/sig/config.rbs +17 -0
- data/sig/cookie.rbs +37 -0
- data/sig/htmlutils.rbs +5 -0
- data/sig/httpauth/authenticator.rbs +55 -0
- data/sig/httpauth/basicauth.rbs +29 -0
- data/sig/httpauth/digestauth.rbs +85 -0
- data/sig/httpauth/htdigest.rbs +31 -0
- data/sig/httpauth/htgroup.rbs +21 -0
- data/sig/httpauth/htpasswd.rbs +31 -0
- data/sig/httpauth/userdb.rbs +13 -0
- data/sig/httpauth.rbs +13 -0
- data/sig/httpproxy.rbs +61 -0
- data/sig/httprequest.rbs +167 -0
- data/sig/httpresponse.rbs +117 -0
- data/sig/https.rbs +49 -0
- data/sig/httpserver.rbs +71 -0
- data/sig/httpservlet/abstract.rbs +36 -0
- data/sig/httpservlet/cgi_runner.rbs +3 -0
- data/sig/httpservlet/cgihandler.rbs +23 -0
- data/sig/httpservlet/erbhandler.rbs +17 -0
- data/sig/httpservlet/filehandler.rbs +76 -0
- data/sig/httpservlet/prochandler.rbs +21 -0
- data/sig/httpservlet.rbs +4 -0
- data/sig/httpstatus.rbs +255 -0
- data/sig/httputils.rbs +116 -0
- data/sig/httpversion.rbs +17 -0
- data/sig/log.rbs +93 -0
- data/sig/manifest.yaml +8 -0
- data/sig/server.rbs +57 -0
- data/sig/ssl.rbs +19 -0
- data/sig/utils.rbs +122 -0
- data/sig/version.rbs +3 -0
- data/webrick.gemspec +35 -0
- metadata +43 -5
@@ -0,0 +1,76 @@
|
|
1
|
+
module WEBrick
|
2
|
+
module HTTPServlet
|
3
|
+
class DefaultFileHandler < AbstractServlet
|
4
|
+
@local_path: String
|
5
|
+
|
6
|
+
def initialize: (HTTPServer server, String local_path) -> void
|
7
|
+
|
8
|
+
def do_GET: (HTTPRequest req, HTTPResponse res) -> void
|
9
|
+
|
10
|
+
def not_modified?: (HTTPRequest req, HTTPResponse res, Time mtime, String etag) -> bool
|
11
|
+
|
12
|
+
# returns a lambda for webrick/httpresponse.rb send_body_proc
|
13
|
+
def multipart_body: (File body, Array[[Numeric, Numeric]] parts, String boundary, String mtype, Integer filesize) -> HTTPResponse::_CallableBody
|
14
|
+
|
15
|
+
def make_partial_content: (HTTPRequest req, HTTPResponse res, String filename, Integer filesize) -> void
|
16
|
+
|
17
|
+
def prepare_range: (Range[Integer] range, Integer filesize) -> [Numeric, Numeric]
|
18
|
+
end
|
19
|
+
|
20
|
+
class FileHandler < AbstractServlet
|
21
|
+
@config: AbstractServlet::_Config
|
22
|
+
|
23
|
+
@logger: Log
|
24
|
+
|
25
|
+
@root: String
|
26
|
+
|
27
|
+
@options: Hash[Symbol, untyped]
|
28
|
+
|
29
|
+
HandlerTable: Hash[String, singleton(AbstractServlet)]
|
30
|
+
|
31
|
+
def self.add_handler: (String suffix, singleton(AbstractServlet) handler) -> singleton(AbstractServlet)
|
32
|
+
|
33
|
+
def self.remove_handler: (String suffix) -> singleton(AbstractServlet)
|
34
|
+
|
35
|
+
def initialize: (HTTPServer server, String root, ?Hash[Symbol, untyped] options, ?Hash[Symbol, untyped] default) -> void
|
36
|
+
|
37
|
+
def set_filesystem_encoding: (String str) -> String
|
38
|
+
|
39
|
+
def service: (HTTPRequest req, HTTPResponse res) -> void
|
40
|
+
|
41
|
+
def do_GET: (HTTPRequest req, HTTPResponse res) -> void
|
42
|
+
|
43
|
+
def do_POST: (HTTPRequest req, HTTPResponse res) -> void
|
44
|
+
|
45
|
+
def do_OPTIONS: (HTTPRequest req, HTTPResponse res) -> void
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def trailing_pathsep?: (String path) -> bool
|
50
|
+
|
51
|
+
def prevent_directory_traversal: (HTTPRequest req, HTTPResponse res) -> void
|
52
|
+
|
53
|
+
def exec_handler: (HTTPRequest req, HTTPResponse res) -> bool
|
54
|
+
|
55
|
+
def get_handler: (HTTPRequest req, HTTPResponse res) -> singleton(AbstractServlet)
|
56
|
+
|
57
|
+
def set_filename: (HTTPRequest req, HTTPResponse res) -> bool
|
58
|
+
|
59
|
+
def check_filename: (HTTPRequest req, HTTPResponse res, String name) -> void
|
60
|
+
|
61
|
+
def shift_path_info: (HTTPRequest req, HTTPResponse res, String path_info, ?String? base) -> void
|
62
|
+
|
63
|
+
def search_index_file: (HTTPRequest req, HTTPResponse res) -> String?
|
64
|
+
|
65
|
+
def search_file: (HTTPRequest req, HTTPResponse res, String basename) -> String?
|
66
|
+
|
67
|
+
def call_callback: (Symbol callback_name, HTTPRequest req, HTTPResponse res) -> void
|
68
|
+
|
69
|
+
def windows_ambiguous_name?: (String name) -> bool
|
70
|
+
|
71
|
+
def nondisclosure_name?: (String name) -> bool
|
72
|
+
|
73
|
+
def set_dir_list: (HTTPRequest req, HTTPResponse res) -> void
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module WEBrick
|
2
|
+
module HTTPServlet
|
3
|
+
class ProcHandler < AbstractServlet
|
4
|
+
interface _Callable
|
5
|
+
def call: (WEBrick::HTTPRequest, WEBrick::HTTPResponse) -> void
|
6
|
+
end
|
7
|
+
|
8
|
+
@proc: _Callable
|
9
|
+
|
10
|
+
def get_instance: (HTTPServer server, *untyped options) -> self
|
11
|
+
|
12
|
+
def initialize: (_Callable proc) -> void
|
13
|
+
|
14
|
+
def do_GET: (HTTPRequest request, HTTPResponse response) -> void
|
15
|
+
|
16
|
+
alias do_POST do_GET
|
17
|
+
|
18
|
+
alias do_PUT do_GET
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/sig/httpservlet.rbs
ADDED
data/sig/httpstatus.rbs
ADDED
@@ -0,0 +1,255 @@
|
|
1
|
+
module WEBrick
|
2
|
+
#
|
3
|
+
# This module is used to manager HTTP status codes.
|
4
|
+
#
|
5
|
+
# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more
|
6
|
+
# information.
|
7
|
+
module HTTPStatus
|
8
|
+
#
|
9
|
+
# Root of the HTTP status class hierarchy
|
10
|
+
class Status < StandardError
|
11
|
+
attr_reader self.code: Integer
|
12
|
+
|
13
|
+
attr_reader self.reason_phrase: String
|
14
|
+
|
15
|
+
# Returns the HTTP status code
|
16
|
+
def code: () -> Integer
|
17
|
+
|
18
|
+
# Returns the HTTP status description
|
19
|
+
def reason_phrase: () -> String
|
20
|
+
|
21
|
+
alias to_i code
|
22
|
+
end
|
23
|
+
|
24
|
+
# Root of the HTTP info statuses
|
25
|
+
class Info < Status
|
26
|
+
end
|
27
|
+
|
28
|
+
# Root of the HTTP success statuses
|
29
|
+
class Success < Status
|
30
|
+
end
|
31
|
+
|
32
|
+
# Root of the HTTP redirect statuses
|
33
|
+
class Redirect < Status
|
34
|
+
end
|
35
|
+
|
36
|
+
# Root of the HTTP error statuses
|
37
|
+
class Error < Status
|
38
|
+
end
|
39
|
+
|
40
|
+
# Root of the HTTP client error statuses
|
41
|
+
class ClientError < Error
|
42
|
+
end
|
43
|
+
|
44
|
+
# Root of the HTTP server error statuses
|
45
|
+
class ServerError < Error
|
46
|
+
end
|
47
|
+
|
48
|
+
class EOFError < StandardError
|
49
|
+
end
|
50
|
+
|
51
|
+
# HTTP status codes and descriptions
|
52
|
+
StatusMessage: Hash[Integer, String]
|
53
|
+
|
54
|
+
# Maps a status code to the corresponding Status class
|
55
|
+
CodeToError: Hash[Integer, singleton(Status)]
|
56
|
+
|
57
|
+
# WEBrick::HTTPStatus::constants.grep(/\ARC_/).map{"#{_1}: #{WEBrick::HTTPStatus.const_get(_1)}"}
|
58
|
+
|
59
|
+
RC_CONTINUE: 100
|
60
|
+
RC_SWITCHING_PROTOCOLS: 101
|
61
|
+
RC_OK: 200
|
62
|
+
RC_CREATED: 201
|
63
|
+
RC_ACCEPTED: 202
|
64
|
+
RC_NON_AUTHORITATIVE_INFORMATION: 203
|
65
|
+
RC_NO_CONTENT: 204
|
66
|
+
RC_RESET_CONTENT: 205
|
67
|
+
RC_PARTIAL_CONTENT: 206
|
68
|
+
RC_MULTI_STATUS: 207
|
69
|
+
RC_MULTIPLE_CHOICES: 300
|
70
|
+
RC_MOVED_PERMANENTLY: 301
|
71
|
+
RC_FOUND: 302
|
72
|
+
RC_SEE_OTHER: 303
|
73
|
+
RC_NOT_MODIFIED: 304
|
74
|
+
RC_USE_PROXY: 305
|
75
|
+
RC_TEMPORARY_REDIRECT: 307
|
76
|
+
RC_BAD_REQUEST: 400
|
77
|
+
RC_UNAUTHORIZED: 401
|
78
|
+
RC_PAYMENT_REQUIRED: 402
|
79
|
+
RC_FORBIDDEN: 403
|
80
|
+
RC_NOT_FOUND: 404
|
81
|
+
RC_METHOD_NOT_ALLOWED: 405
|
82
|
+
RC_NOT_ACCEPTABLE: 406
|
83
|
+
RC_PROXY_AUTHENTICATION_REQUIRED: 407
|
84
|
+
RC_REQUEST_TIMEOUT: 408
|
85
|
+
RC_CONFLICT: 409
|
86
|
+
RC_GONE: 410
|
87
|
+
RC_PRECONDITION_FAILED: 412
|
88
|
+
RC_LENGTH_REQUIRED: 411
|
89
|
+
RC_REQUEST_ENTITY_TOO_LARGE: 413
|
90
|
+
RC_REQUEST_URI_TOO_LARGE: 414
|
91
|
+
RC_UNSUPPORTED_MEDIA_TYPE: 415
|
92
|
+
RC_EXPECTATION_FAILED: 417
|
93
|
+
RC_UNPROCESSABLE_ENTITY: 422
|
94
|
+
RC_LOCKED: 423
|
95
|
+
RC_FAILED_DEPENDENCY: 424
|
96
|
+
RC_REQUEST_RANGE_NOT_SATISFIABLE: 416
|
97
|
+
RC_UPGRADE_REQUIRED: 426
|
98
|
+
RC_PRECONDITION_REQUIRED: 428
|
99
|
+
RC_TOO_MANY_REQUESTS: 429
|
100
|
+
RC_REQUEST_HEADER_FIELDS_TOO_LARGE: 431
|
101
|
+
RC_UNAVAILABLE_FOR_LEGAL_REASONS: 451
|
102
|
+
RC_INTERNAL_SERVER_ERROR: 500
|
103
|
+
RC_NOT_IMPLEMENTED: 501
|
104
|
+
RC_BAD_GATEWAY: 502
|
105
|
+
RC_SERVICE_UNAVAILABLE: 503
|
106
|
+
RC_GATEWAY_TIMEOUT: 504
|
107
|
+
RC_HTTP_VERSION_NOT_SUPPORTED: 505
|
108
|
+
RC_INSUFFICIENT_STORAGE: 507
|
109
|
+
RC_NETWORK_AUTHENTICATION_REQUIRED: 511
|
110
|
+
|
111
|
+
# WEBrick::HTTPStatus::CodeToError.each_value.map{"class #{_1.name.split(/::/).last} < #{_1.superclass.name.split(/::/).last}\nend"}
|
112
|
+
|
113
|
+
class Continue < Info
|
114
|
+
end
|
115
|
+
class SwitchingProtocols < Info
|
116
|
+
end
|
117
|
+
class OK < Success
|
118
|
+
end
|
119
|
+
class Created < Success
|
120
|
+
end
|
121
|
+
class Accepted < Success
|
122
|
+
end
|
123
|
+
class NonAuthoritativeInformation < Success
|
124
|
+
end
|
125
|
+
class NoContent < Success
|
126
|
+
end
|
127
|
+
class ResetContent < Success
|
128
|
+
end
|
129
|
+
class PartialContent < Success
|
130
|
+
end
|
131
|
+
class MultiStatus < Success
|
132
|
+
end
|
133
|
+
class MultipleChoices < Redirect
|
134
|
+
end
|
135
|
+
class MovedPermanently < Redirect
|
136
|
+
end
|
137
|
+
class Found < Redirect
|
138
|
+
end
|
139
|
+
class SeeOther < Redirect
|
140
|
+
end
|
141
|
+
class NotModified < Redirect
|
142
|
+
end
|
143
|
+
class UseProxy < Redirect
|
144
|
+
end
|
145
|
+
class TemporaryRedirect < Redirect
|
146
|
+
end
|
147
|
+
class BadRequest < ClientError
|
148
|
+
end
|
149
|
+
class Unauthorized < ClientError
|
150
|
+
end
|
151
|
+
class PaymentRequired < ClientError
|
152
|
+
end
|
153
|
+
class Forbidden < ClientError
|
154
|
+
end
|
155
|
+
class NotFound < ClientError
|
156
|
+
end
|
157
|
+
class MethodNotAllowed < ClientError
|
158
|
+
end
|
159
|
+
class NotAcceptable < ClientError
|
160
|
+
end
|
161
|
+
class ProxyAuthenticationRequired < ClientError
|
162
|
+
end
|
163
|
+
class RequestTimeout < ClientError
|
164
|
+
end
|
165
|
+
class Conflict < ClientError
|
166
|
+
end
|
167
|
+
class Gone < ClientError
|
168
|
+
end
|
169
|
+
class LengthRequired < ClientError
|
170
|
+
end
|
171
|
+
class PreconditionFailed < ClientError
|
172
|
+
end
|
173
|
+
class RequestEntityTooLarge < ClientError
|
174
|
+
end
|
175
|
+
class RequestURITooLarge < ClientError
|
176
|
+
end
|
177
|
+
class UnsupportedMediaType < ClientError
|
178
|
+
end
|
179
|
+
class RequestRangeNotSatisfiable < ClientError
|
180
|
+
end
|
181
|
+
class ExpectationFailed < ClientError
|
182
|
+
end
|
183
|
+
class UnprocessableEntity < ClientError
|
184
|
+
end
|
185
|
+
class Locked < ClientError
|
186
|
+
end
|
187
|
+
class FailedDependency < ClientError
|
188
|
+
end
|
189
|
+
class UpgradeRequired < ClientError
|
190
|
+
end
|
191
|
+
class PreconditionRequired < ClientError
|
192
|
+
end
|
193
|
+
class TooManyRequests < ClientError
|
194
|
+
end
|
195
|
+
class RequestHeaderFieldsTooLarge < ClientError
|
196
|
+
end
|
197
|
+
class UnavailableForLegalReasons < ClientError
|
198
|
+
end
|
199
|
+
class InternalServerError < ServerError
|
200
|
+
end
|
201
|
+
class NotImplemented < ServerError
|
202
|
+
end
|
203
|
+
class BadGateway < ServerError
|
204
|
+
end
|
205
|
+
class ServiceUnavailable < ServerError
|
206
|
+
end
|
207
|
+
class GatewayTimeout < ServerError
|
208
|
+
end
|
209
|
+
class HTTPVersionNotSupported < ServerError
|
210
|
+
end
|
211
|
+
class InsufficientStorage < ServerError
|
212
|
+
end
|
213
|
+
class NetworkAuthenticationRequired < ServerError
|
214
|
+
end
|
215
|
+
|
216
|
+
#
|
217
|
+
# Returns the description corresponding to the HTTP status +code+
|
218
|
+
#
|
219
|
+
# WEBrick::HTTPStatus.reason_phrase 404
|
220
|
+
# => "Not Found"
|
221
|
+
def self?.reason_phrase: (Integer code) -> String
|
222
|
+
|
223
|
+
#
|
224
|
+
# Is +code+ an informational status?
|
225
|
+
def self?.info?: (Integer code) -> bool
|
226
|
+
|
227
|
+
#
|
228
|
+
# Is +code+ a successful status?
|
229
|
+
def self?.success?: (Integer code) -> bool
|
230
|
+
|
231
|
+
#
|
232
|
+
# Is +code+ a redirection status?
|
233
|
+
def self?.redirect?: (Integer code) -> bool
|
234
|
+
|
235
|
+
#
|
236
|
+
# Is +code+ an error status?
|
237
|
+
def self?.error?: (Integer code) -> bool
|
238
|
+
|
239
|
+
#
|
240
|
+
# Is +code+ a client error status?
|
241
|
+
def self?.client_error?: (Integer code) -> bool
|
242
|
+
|
243
|
+
#
|
244
|
+
# Is +code+ a server error status?
|
245
|
+
def self?.server_error?: (Integer code) -> bool
|
246
|
+
|
247
|
+
#
|
248
|
+
# Returns the status class corresponding to +code+
|
249
|
+
#
|
250
|
+
# WEBrick::HTTPStatus[302]
|
251
|
+
# => WEBrick::HTTPStatus::NotFound
|
252
|
+
#
|
253
|
+
def self.[]: (Integer code) -> singleton(Status)
|
254
|
+
end
|
255
|
+
end
|
data/sig/httputils.rbs
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
module WEBrick
|
2
|
+
CR: String
|
3
|
+
|
4
|
+
LF: String
|
5
|
+
|
6
|
+
CRLF: String
|
7
|
+
|
8
|
+
module HTTPUtils
|
9
|
+
def self?.normalize_path: (String path) -> String
|
10
|
+
|
11
|
+
type mime_types = Hash[String, String]
|
12
|
+
|
13
|
+
DefaultMimeTypes: mime_types
|
14
|
+
|
15
|
+
def self?.load_mime_types: (string | _ToPath file) -> mime_types
|
16
|
+
|
17
|
+
def self?.mime_type: (String filename, mime_types mime_tab) -> String
|
18
|
+
|
19
|
+
class SplitHeader < Array[String]
|
20
|
+
def join: (?String separator) -> String
|
21
|
+
end
|
22
|
+
|
23
|
+
class CookieHeader < Array[String]
|
24
|
+
def join: (?String separator) -> String
|
25
|
+
end
|
26
|
+
|
27
|
+
HEADER_CLASSES: Hash[String, untyped]
|
28
|
+
|
29
|
+
def self?.parse_header: (String raw) -> Hash[String, Array[String]]
|
30
|
+
|
31
|
+
def self?.split_header_value: (String str) -> Array[String]
|
32
|
+
|
33
|
+
def self?.parse_range_header: (String? ranges_specifier) -> Array[Range[Integer]]?
|
34
|
+
|
35
|
+
def self?.parse_qvalues: (String? value) -> Array[String]
|
36
|
+
|
37
|
+
def self?.dequote: (String str) -> String
|
38
|
+
|
39
|
+
def self?.quote: (String str) -> String
|
40
|
+
|
41
|
+
class FormData < String
|
42
|
+
@raw_header: Array[String]
|
43
|
+
|
44
|
+
@header: Hash[String, Array[String]]
|
45
|
+
|
46
|
+
EmptyRawHeader: Array[String]
|
47
|
+
|
48
|
+
EmptyHeader: Hash[String, Array[String]]
|
49
|
+
|
50
|
+
attr_accessor name: String?
|
51
|
+
|
52
|
+
attr_accessor filename: String?
|
53
|
+
|
54
|
+
attr_accessor next_data: instance?
|
55
|
+
|
56
|
+
def initialize: (*String args) -> void
|
57
|
+
|
58
|
+
def []: (*String key) -> String
|
59
|
+
# following is as same as String#[]
|
60
|
+
| (int start, ?int length) -> String?
|
61
|
+
| (range[int?] range) -> String?
|
62
|
+
| (Regexp regexp, ?MatchData::capture backref) -> String?
|
63
|
+
| (String substring) -> String?
|
64
|
+
|
65
|
+
def <<: (String str) -> self
|
66
|
+
|
67
|
+
def append_data: (instance data) -> self
|
68
|
+
|
69
|
+
def each_data: () { (instance) -> void } -> void
|
70
|
+
|
71
|
+
def list: () -> Array[String]
|
72
|
+
|
73
|
+
alias to_ary list
|
74
|
+
|
75
|
+
def to_s: () -> String
|
76
|
+
end
|
77
|
+
|
78
|
+
def self?.parse_query: (String? str) -> Hash[String, FormData]
|
79
|
+
|
80
|
+
interface _EachLine
|
81
|
+
def each_line: () { (String) -> void } -> void
|
82
|
+
end
|
83
|
+
|
84
|
+
def self?.parse_form_data: (_EachLine? io, interned boundary) -> Hash[String, FormData]
|
85
|
+
|
86
|
+
def self?._make_regex: (String str) -> Regexp
|
87
|
+
|
88
|
+
def self?._make_regex!: (String str) -> Regexp
|
89
|
+
|
90
|
+
def self?._escape: (String str, Regexp regex) -> String
|
91
|
+
|
92
|
+
def self?._unescape: (String str, Regexp regex) -> String
|
93
|
+
|
94
|
+
UNESCAPED: Regexp
|
95
|
+
|
96
|
+
UNESCAPED_FORM: Regexp
|
97
|
+
|
98
|
+
NONASCII: Regexp
|
99
|
+
|
100
|
+
ESCAPED: Regexp
|
101
|
+
|
102
|
+
UNESCAPED_PCHAR: Regexp
|
103
|
+
|
104
|
+
def self?.escape: (String str) -> String
|
105
|
+
|
106
|
+
def self?.unescape: (String str) -> String
|
107
|
+
|
108
|
+
def self?.escape_form: (String str) -> String
|
109
|
+
|
110
|
+
def self?.unescape_form: (String str) -> String
|
111
|
+
|
112
|
+
def self?.escape_path: (String str) -> String
|
113
|
+
|
114
|
+
def self?.escape8bit: (String str) -> String
|
115
|
+
end
|
116
|
+
end
|
data/sig/httpversion.rbs
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module WEBrick
|
2
|
+
class HTTPVersion
|
3
|
+
include Comparable
|
4
|
+
|
5
|
+
attr_accessor major: Integer
|
6
|
+
|
7
|
+
attr_accessor minor: Integer
|
8
|
+
|
9
|
+
def self.convert: (HTTPVersion | String version) -> instance
|
10
|
+
|
11
|
+
def initialize: (HTTPVersion | String version) -> void
|
12
|
+
|
13
|
+
def <=>: (HTTPVersion | String other) -> Integer?
|
14
|
+
|
15
|
+
def to_s: () -> String
|
16
|
+
end
|
17
|
+
end
|
data/sig/log.rbs
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
module WEBrick
|
2
|
+
class BasicLog
|
3
|
+
@log: IO?
|
4
|
+
|
5
|
+
@opened: TrueClass?
|
6
|
+
|
7
|
+
FATAL: 1
|
8
|
+
|
9
|
+
ERROR: 2
|
10
|
+
|
11
|
+
WARN: 3
|
12
|
+
|
13
|
+
INFO: 4
|
14
|
+
|
15
|
+
DEBUG: 5
|
16
|
+
|
17
|
+
# log-level, messages above this level will be logged
|
18
|
+
attr_accessor level: Integer
|
19
|
+
|
20
|
+
type log_file = (IO | String)?
|
21
|
+
|
22
|
+
def initialize: (?log_file log_file, ?Integer? level) -> void
|
23
|
+
|
24
|
+
#
|
25
|
+
# Closes the logger (also closes the log device associated to the logger)
|
26
|
+
def close: () -> void
|
27
|
+
|
28
|
+
def log: (Integer level, String data) -> IO?
|
29
|
+
|
30
|
+
#
|
31
|
+
# Synonym for log(INFO, obj.to_s)
|
32
|
+
def <<: (_ToS obj) -> IO?
|
33
|
+
|
34
|
+
type message = Exception | _ToStr | Object
|
35
|
+
|
36
|
+
# Shortcut for logging a FATAL message
|
37
|
+
def fatal: (message msg) -> IO?
|
38
|
+
|
39
|
+
# Shortcut for logging an ERROR message
|
40
|
+
def error: (message msg) -> IO?
|
41
|
+
|
42
|
+
# Shortcut for logging a WARN message
|
43
|
+
def warn: (message msg) -> IO?
|
44
|
+
|
45
|
+
# Shortcut for logging an INFO message
|
46
|
+
def info: (message msg) -> IO?
|
47
|
+
|
48
|
+
# Shortcut for logging a DEBUG message
|
49
|
+
def debug: (message msg) -> IO?
|
50
|
+
|
51
|
+
# Will the logger output FATAL messages?
|
52
|
+
def fatal?: () -> bool
|
53
|
+
|
54
|
+
# Will the logger output ERROR messages?
|
55
|
+
def error?: () -> bool
|
56
|
+
|
57
|
+
# Will the logger output WARN messages?
|
58
|
+
def warn?: () -> bool
|
59
|
+
|
60
|
+
# Will the logger output INFO messages?
|
61
|
+
def info?: () -> bool
|
62
|
+
|
63
|
+
# Will the logger output DEBUG messages?
|
64
|
+
def debug?: () -> bool
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
#
|
69
|
+
# Formats +arg+ for the logger
|
70
|
+
#
|
71
|
+
# * If +arg+ is an Exception, it will format the error message and
|
72
|
+
# the back trace.
|
73
|
+
# * If +arg+ responds to #to_str, it will return it.
|
74
|
+
# * Otherwise it will return +arg+.inspect.
|
75
|
+
def format: (message arg) -> String
|
76
|
+
end
|
77
|
+
|
78
|
+
class Log < BasicLog
|
79
|
+
# Format of the timestamp which is applied to each logged line. The
|
80
|
+
# default is <tt>"[%Y-%m-%d %H:%M:%S]"</tt>
|
81
|
+
attr_accessor time_format: String
|
82
|
+
|
83
|
+
#
|
84
|
+
# Same as BasicLog#initialize
|
85
|
+
#
|
86
|
+
# You can set the timestamp format through #time_format
|
87
|
+
def initialize: (?BasicLog::log_file log_file, ?Integer? level) -> void
|
88
|
+
|
89
|
+
#
|
90
|
+
# Same as BasicLog#log
|
91
|
+
def log: (Integer level, String data) -> IO?
|
92
|
+
end
|
93
|
+
end
|
data/sig/manifest.yaml
ADDED
data/sig/server.rbs
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
module WEBrick
|
2
|
+
class ServerError < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
class SimpleServer
|
6
|
+
def self.start: [T] () { () -> T } -> T
|
7
|
+
end
|
8
|
+
|
9
|
+
class Daemon
|
10
|
+
def self.start: () -> void
|
11
|
+
| [T] () { () -> T } -> T
|
12
|
+
end
|
13
|
+
|
14
|
+
class GenericServer
|
15
|
+
@shutdown_pipe: [IO, IO]?
|
16
|
+
|
17
|
+
attr_reader status: :Stop | :Running | :Shutdown
|
18
|
+
|
19
|
+
attr_reader config: Hash[Symbol, untyped]
|
20
|
+
|
21
|
+
attr_reader logger: BasicLog
|
22
|
+
|
23
|
+
attr_reader tokens: Thread::SizedQueue
|
24
|
+
|
25
|
+
attr_reader listeners: Array[TCPServer| OpenSSL::SSL::SSLServer]
|
26
|
+
|
27
|
+
def initialize: (?Hash[Symbol, untyped] config, ?Hash[Symbol, untyped] default) -> void
|
28
|
+
|
29
|
+
def []: (Symbol key) -> untyped
|
30
|
+
|
31
|
+
def listen: (String address, Integer port) -> void
|
32
|
+
|
33
|
+
def start: () ?{ (TCPSocket) -> void } -> void
|
34
|
+
|
35
|
+
def stop: () -> void
|
36
|
+
|
37
|
+
def shutdown: () -> void
|
38
|
+
|
39
|
+
def run: (TCPSocket sock) -> void
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def accept_client: (TCPServer svr) -> TCPSocket?
|
44
|
+
|
45
|
+
def start_thread: (TCPSocket sock) ?{ (TCPSocket) -> void } -> Thread
|
46
|
+
|
47
|
+
def call_callback: (Symbol callback_name, *untyped args) -> untyped
|
48
|
+
|
49
|
+
def setup_shutdown_pipe: () -> [IO, IO]
|
50
|
+
|
51
|
+
def cleanup_shutdown_pipe: ([IO, IO]? shutdown_pipe) -> void
|
52
|
+
|
53
|
+
def alarm_shutdown_pipe: [T] () { (IO) -> T } -> T?
|
54
|
+
|
55
|
+
def cleanup_listener: () -> void
|
56
|
+
end
|
57
|
+
end
|
data/sig/ssl.rbs
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module WEBrick
|
2
|
+
module Config
|
3
|
+
SSL: Hash[Symbol, untyped]
|
4
|
+
end
|
5
|
+
|
6
|
+
module Utils
|
7
|
+
def self?.create_self_signed_cert: (untyped bits, untyped cn, untyped comment) -> ::Array[untyped]
|
8
|
+
end
|
9
|
+
|
10
|
+
class GenericServer
|
11
|
+
@ssl_context: OpenSSL::SSL::SSLContext?
|
12
|
+
|
13
|
+
def ssl_context: () -> OpenSSL::SSL::SSLContext?
|
14
|
+
|
15
|
+
def setup_ssl_context: (Hash[Symbol, untyped] config) -> OpenSSL::SSL::SSLContext
|
16
|
+
|
17
|
+
def ssl_servername_callback: (untyped sslsocket, ?untyped? hostname) -> untyped
|
18
|
+
end
|
19
|
+
end
|