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,31 @@
|
|
1
|
+
module WEBrick
|
2
|
+
module HTTPAuth
|
3
|
+
class Htdigest
|
4
|
+
@path: String
|
5
|
+
|
6
|
+
@mtime: Time
|
7
|
+
|
8
|
+
@digest: Hash[String, Hash[String, String]]
|
9
|
+
|
10
|
+
@mutex: Thread::Mutex
|
11
|
+
|
12
|
+
@auth_type: String
|
13
|
+
|
14
|
+
include UserDB
|
15
|
+
|
16
|
+
def initialize: (String path) -> void
|
17
|
+
|
18
|
+
def reload: () -> void
|
19
|
+
|
20
|
+
def flush: (?String? output) -> void
|
21
|
+
|
22
|
+
def get_passwd: (String realm, String user, bool reload_db) -> String?
|
23
|
+
|
24
|
+
def set_passwd: (String realm, String user, String pass) -> String
|
25
|
+
|
26
|
+
def delete_passwd: (String realm, String user) -> String?
|
27
|
+
|
28
|
+
def each: () { (String user, String realm, String password_hash) -> void } -> void
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module WEBrick
|
2
|
+
module HTTPAuth
|
3
|
+
class Htgroup
|
4
|
+
@path: String
|
5
|
+
|
6
|
+
@mtime: Time
|
7
|
+
|
8
|
+
@group: Hash[String, Array[String]]
|
9
|
+
|
10
|
+
def initialize: (String path) -> void
|
11
|
+
|
12
|
+
def reload: () -> void
|
13
|
+
|
14
|
+
def flush: (?String? output) -> void
|
15
|
+
|
16
|
+
def members: (String group) -> Array[String]
|
17
|
+
|
18
|
+
def add: (String group, Array[String] members) -> void
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module WEBrick
|
2
|
+
module HTTPAuth
|
3
|
+
class Htpasswd
|
4
|
+
@path: String
|
5
|
+
|
6
|
+
@mtime: Time
|
7
|
+
|
8
|
+
@passwd: Hash[String, String]
|
9
|
+
|
10
|
+
@auth_type: String
|
11
|
+
|
12
|
+
@password_hash: (:crypt | :bcrypt)
|
13
|
+
|
14
|
+
include UserDB
|
15
|
+
|
16
|
+
def initialize: (String path, ?password_hash: (:crypt | :bcrypt)?) -> void
|
17
|
+
|
18
|
+
def reload: () -> void
|
19
|
+
|
20
|
+
def flush: (?String? output) -> void
|
21
|
+
|
22
|
+
def get_passwd: (String realm, String user, bool reload_db) -> String?
|
23
|
+
|
24
|
+
def set_passwd: (String realm, String user, String pass) -> void
|
25
|
+
|
26
|
+
def delete_passwd: (String realm, String user) -> String
|
27
|
+
|
28
|
+
def each: () { ([String, String]) -> void } -> void
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module WEBrick
|
2
|
+
module HTTPAuth
|
3
|
+
module UserDB
|
4
|
+
attr_accessor auth_type: String
|
5
|
+
|
6
|
+
def make_passwd: (String realm, String user, String pass) -> String
|
7
|
+
|
8
|
+
def set_passwd: (String realm, String user, String pass) -> void
|
9
|
+
|
10
|
+
def get_passwd: (String realm, String user, ?bool reload_db) -> String
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/sig/httpauth.rbs
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module WEBrick
|
2
|
+
module HTTPAuth
|
3
|
+
interface _Callable
|
4
|
+
def call: (String user, String pass) -> bool
|
5
|
+
end
|
6
|
+
|
7
|
+
def self?._basic_auth: (HTTPRequest req, HTTPResponse res, String realm, String req_field, String res_field, HTTPStatus::Error err_type, _Callable block) -> void
|
8
|
+
|
9
|
+
def self?.basic_auth: (HTTPRequest req, HTTPResponse res, String realm) { (String user, String pass) -> bool } -> void
|
10
|
+
|
11
|
+
def self?.proxy_basic_auth: (HTTPRequest req, HTTPResponse res, String realm) { (String user, String pass) -> bool } -> void
|
12
|
+
end
|
13
|
+
end
|
data/sig/httpproxy.rbs
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
module WEBrick
|
2
|
+
NullReader: untyped
|
3
|
+
|
4
|
+
def self.read: (*untyped args) -> nil
|
5
|
+
|
6
|
+
alias self.gets self.read
|
7
|
+
|
8
|
+
FakeProxyURI: untyped
|
9
|
+
|
10
|
+
def self.method_missing: (untyped meth, *untyped args) -> (nil | untyped)
|
11
|
+
|
12
|
+
class HTTPProxyServer < HTTPServer
|
13
|
+
@via: untyped
|
14
|
+
|
15
|
+
def initialize: (?::Hash[untyped, untyped] config, ?untyped default) -> void
|
16
|
+
|
17
|
+
# :stopdoc:
|
18
|
+
def service: (HTTPRequest req, HTTPResponse res) -> untyped
|
19
|
+
|
20
|
+
def proxy_auth: (HTTPRequest req, HTTPResponse res) -> untyped
|
21
|
+
|
22
|
+
def proxy_uri: (HTTPRequest req, HTTPResponse res) -> untyped
|
23
|
+
|
24
|
+
def proxy_service: (HTTPRequest req, HTTPResponse res) -> untyped
|
25
|
+
|
26
|
+
def do_CONNECT: (HTTPRequest req, HTTPResponse res) -> untyped
|
27
|
+
|
28
|
+
def do_GET: (HTTPRequest req, HTTPResponse res) -> untyped
|
29
|
+
|
30
|
+
def do_HEAD: (HTTPRequest req, HTTPResponse res) -> untyped
|
31
|
+
|
32
|
+
def do_POST: (HTTPRequest req, HTTPResponse res) -> untyped
|
33
|
+
|
34
|
+
def do_OPTIONS: (HTTPRequest req, HTTPResponse res) -> untyped
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# Some header fields should not be transferred.
|
39
|
+
HopByHop: ::Array["connection" | "keep-alive" | "proxy-authenticate" | "upgrade" | "proxy-authorization" | "te" | "trailers" | "transfer-encoding"]
|
40
|
+
|
41
|
+
ShouldNotTransfer: ::Array["set-cookie" | "proxy-connection"]
|
42
|
+
|
43
|
+
def split_field: (untyped f) -> (untyped | ::Array[untyped])
|
44
|
+
|
45
|
+
def choose_header: (untyped src, untyped dst) -> untyped
|
46
|
+
|
47
|
+
# Net::HTTP is stupid about the multiple header fields.
|
48
|
+
# Here is workaround:
|
49
|
+
def set_cookie: (untyped src, untyped dst) -> (untyped | nil)
|
50
|
+
|
51
|
+
def set_via: (untyped h) -> (untyped | nil)
|
52
|
+
|
53
|
+
def setup_proxy_header: (HTTPRequest req, HTTPResponse res) -> untyped
|
54
|
+
|
55
|
+
def setup_upstream_proxy_authentication: (HTTPRequest req, HTTPResponse res, untyped header) -> untyped
|
56
|
+
|
57
|
+
def create_net_http: (untyped uri, untyped upstream) -> untyped
|
58
|
+
|
59
|
+
def perform_proxy_request: (HTTPRequest req, HTTPResponse res, untyped req_class, ?untyped? body_stream) -> untyped
|
60
|
+
end
|
61
|
+
end
|
data/sig/httprequest.rbs
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
module WEBrick
|
2
|
+
class HTTPRequest
|
3
|
+
@config: Hash[Symbol, untyped]
|
4
|
+
|
5
|
+
@buffer_size: Integer
|
6
|
+
|
7
|
+
@logger: Log
|
8
|
+
|
9
|
+
@query: Hash[String, HTTPUtils::FormData]?
|
10
|
+
|
11
|
+
@body: String
|
12
|
+
|
13
|
+
@remaining_size: Integer?
|
14
|
+
|
15
|
+
@socket: TCPSocket?
|
16
|
+
|
17
|
+
@forwarded_proto: String?
|
18
|
+
|
19
|
+
@host: String?
|
20
|
+
|
21
|
+
@port: Integer?
|
22
|
+
|
23
|
+
@body_tmp: Array[String]
|
24
|
+
|
25
|
+
@body_rd: Fiber
|
26
|
+
|
27
|
+
@request_bytes: Integer
|
28
|
+
|
29
|
+
@forwarded_server: String?
|
30
|
+
|
31
|
+
@forwarded_host: String?
|
32
|
+
|
33
|
+
@forwarded_port: Integer?
|
34
|
+
|
35
|
+
@forwarded_for: String?
|
36
|
+
|
37
|
+
BODY_CONTAINABLE_METHODS: Array[String]
|
38
|
+
|
39
|
+
attr_reader request_line: String?
|
40
|
+
|
41
|
+
attr_reader request_method: String?
|
42
|
+
|
43
|
+
attr_reader unparsed_uri: String?
|
44
|
+
|
45
|
+
attr_reader http_version: HTTPVersion?
|
46
|
+
|
47
|
+
attr_reader request_uri: URI::Generic?
|
48
|
+
|
49
|
+
attr_reader path: String?
|
50
|
+
|
51
|
+
attr_accessor script_name: String?
|
52
|
+
|
53
|
+
attr_accessor path_info: String?
|
54
|
+
|
55
|
+
attr_accessor query_string: String?
|
56
|
+
|
57
|
+
attr_reader raw_header: Array[String]
|
58
|
+
|
59
|
+
attr_reader header: Hash[String, Array[String]]?
|
60
|
+
|
61
|
+
attr_reader cookies: Array[Cookie]
|
62
|
+
|
63
|
+
attr_reader accept: Array[String]
|
64
|
+
|
65
|
+
attr_reader accept_charset: Array[String]
|
66
|
+
|
67
|
+
attr_reader accept_encoding: Array[String]
|
68
|
+
|
69
|
+
attr_reader accept_language: Array[String]
|
70
|
+
|
71
|
+
attr_accessor user: String?
|
72
|
+
|
73
|
+
attr_reader addr: ([String, Integer, String, String] | [])
|
74
|
+
|
75
|
+
attr_reader peeraddr: ([String, Integer, String, String] | [])
|
76
|
+
|
77
|
+
attr_reader attributes: Hash[untyped, untyped]
|
78
|
+
|
79
|
+
attr_reader keep_alive: bool
|
80
|
+
|
81
|
+
attr_reader request_time: Time?
|
82
|
+
|
83
|
+
def initialize: (Hash[Symbol, untyped] config) -> void
|
84
|
+
|
85
|
+
def parse: (?TCPSocket? socket) -> void
|
86
|
+
|
87
|
+
def continue: () -> void
|
88
|
+
|
89
|
+
type body_chunk_block = ^(String body_chunk) -> void
|
90
|
+
|
91
|
+
def body: () ?{ (String body_chunk) -> void } -> String
|
92
|
+
|
93
|
+
def body_reader: () -> self
|
94
|
+
|
95
|
+
# for IO.copy_stream.
|
96
|
+
def readpartial: (Integer size, ?String buf) -> String
|
97
|
+
|
98
|
+
def query: () -> Hash[String, HTTPUtils::FormData]
|
99
|
+
|
100
|
+
def content_length: () -> Integer
|
101
|
+
|
102
|
+
def content_type: () -> String?
|
103
|
+
|
104
|
+
def []: (String header_name) -> String?
|
105
|
+
|
106
|
+
def each: [T] () { (String, String) -> T } -> T?
|
107
|
+
|
108
|
+
def host: () -> String?
|
109
|
+
|
110
|
+
def port: () -> Integer?
|
111
|
+
|
112
|
+
def server_name: () -> String?
|
113
|
+
|
114
|
+
def remote_ip: () -> String?
|
115
|
+
|
116
|
+
def ssl?: () -> bool
|
117
|
+
|
118
|
+
def keep_alive?: () -> bool
|
119
|
+
|
120
|
+
def to_s: () -> String
|
121
|
+
|
122
|
+
def fixup: () -> void
|
123
|
+
|
124
|
+
def meta_vars: () -> Hash[String, String]
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
MAX_URI_LENGTH: Integer
|
129
|
+
|
130
|
+
# same as Mongrel, Thin and Puma
|
131
|
+
MAX_HEADER_LENGTH: Integer
|
132
|
+
|
133
|
+
def read_request_line: (IO socket) -> void
|
134
|
+
|
135
|
+
def read_header: (IO socket) -> void
|
136
|
+
|
137
|
+
def parse_uri: (String str, ?String scheme) -> URI::Generic
|
138
|
+
|
139
|
+
HOST_PATTERN: Regexp
|
140
|
+
|
141
|
+
def parse_host_request_line: (String host) -> [String, String]
|
142
|
+
|
143
|
+
def read_body: (IO socket, body_chunk_block block) -> String
|
144
|
+
| (nil socket, top block) -> nil
|
145
|
+
|
146
|
+
def read_chunk_size: (IO socket) -> [Integer, String?]
|
147
|
+
|
148
|
+
def read_chunked: (IO socket, body_chunk_block block) -> void
|
149
|
+
|
150
|
+
def _read_data: (IO io, Symbol method, *untyped arg) -> String?
|
151
|
+
|
152
|
+
def read_line: (IO io, ?Integer size) -> String?
|
153
|
+
|
154
|
+
def read_data: (IO io, Integer size) -> String?
|
155
|
+
|
156
|
+
def parse_query: () -> void
|
157
|
+
|
158
|
+
PrivateNetworkRegexp: Regexp
|
159
|
+
|
160
|
+
# It's said that all X-Forwarded-* headers will contain more than one
|
161
|
+
# (comma-separated) value if the original request already contained one of
|
162
|
+
# these headers. Since we could use these values as Host header, we choose
|
163
|
+
# the initial(first) value. (apr_table_mergen() adds new value after the
|
164
|
+
# existing value with ", " prefix)
|
165
|
+
def setup_forwarded_info: () -> void
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module WEBrick
|
2
|
+
class HTTPResponse
|
3
|
+
@buffer_size: Integer
|
4
|
+
|
5
|
+
@logger: Log
|
6
|
+
|
7
|
+
@chunked: bool
|
8
|
+
|
9
|
+
@bodytempfile: File | Tempfile | nil
|
10
|
+
|
11
|
+
class InvalidHeader < StandardError
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader http_version: HTTPVersion
|
15
|
+
|
16
|
+
attr_reader status: Integer
|
17
|
+
|
18
|
+
attr_reader header: Hash[String, String]
|
19
|
+
|
20
|
+
attr_reader cookies: Array[Cookie]
|
21
|
+
|
22
|
+
attr_accessor reason_phrase: String
|
23
|
+
|
24
|
+
interface _CallableBody
|
25
|
+
def call: (_Writer) -> void
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_accessor body: String | _ReaderPartial | _CallableBody
|
29
|
+
|
30
|
+
attr_accessor request_method: String?
|
31
|
+
|
32
|
+
attr_accessor request_uri: URI::Generic?
|
33
|
+
|
34
|
+
attr_accessor request_http_version: HTTPVersion?
|
35
|
+
|
36
|
+
attr_accessor filename: String?
|
37
|
+
|
38
|
+
attr_accessor keep_alive: bool
|
39
|
+
|
40
|
+
attr_reader config: Hash[Symbol, untyped]
|
41
|
+
|
42
|
+
attr_reader sent_size: Integer
|
43
|
+
|
44
|
+
attr_accessor upgrade: String?
|
45
|
+
|
46
|
+
def initialize: (Hash[Symbol, untyped] config) -> void
|
47
|
+
|
48
|
+
def status_line: () -> String
|
49
|
+
|
50
|
+
def status=: (Integer status) -> Integer
|
51
|
+
|
52
|
+
def []: (String field) -> String?
|
53
|
+
|
54
|
+
def []=: (String field, _ToS value) -> _ToS
|
55
|
+
|
56
|
+
def content_length: () -> Integer?
|
57
|
+
|
58
|
+
def content_length=: (Integer len) -> Integer
|
59
|
+
|
60
|
+
def content_type: () -> String?
|
61
|
+
|
62
|
+
def content_type=: (String type) -> String
|
63
|
+
|
64
|
+
def each: () { (String, String) -> void } -> void
|
65
|
+
|
66
|
+
def chunked?: () -> bool
|
67
|
+
|
68
|
+
def chunked=: (boolish val) -> boolish
|
69
|
+
|
70
|
+
def keep_alive?: () -> bool
|
71
|
+
|
72
|
+
def upgrade!: (String protocol) -> void
|
73
|
+
|
74
|
+
def send_response: (_Writer socket) -> void
|
75
|
+
|
76
|
+
def setup_header: () -> void
|
77
|
+
|
78
|
+
def make_body_tempfile: () -> void
|
79
|
+
|
80
|
+
def remove_body_tempfile: () -> void
|
81
|
+
|
82
|
+
def send_header: (_Writer socket) -> void
|
83
|
+
|
84
|
+
def send_body: (_Writer socket) -> void
|
85
|
+
|
86
|
+
def set_redirect: (singleton(WEBrick::HTTPStatus::Redirect) status, URI::Generic | String url) -> bot
|
87
|
+
|
88
|
+
def set_error: (singleton(Exception) ex, ?bool backtrace) -> void
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def check_header: (_ToS header_value) -> String
|
93
|
+
|
94
|
+
def error_body: (bool backtrace, singleton(Exception) ex, String? host, Integer? port) -> void
|
95
|
+
|
96
|
+
def send_body_io: (_Writer socket) -> void
|
97
|
+
|
98
|
+
def send_body_string: (_Writer socket) -> void
|
99
|
+
|
100
|
+
def send_body_proc: (_Writer socket) -> void
|
101
|
+
|
102
|
+
class ChunkedWrapper
|
103
|
+
@socket: _Writer
|
104
|
+
|
105
|
+
@resp: HTTPResponse
|
106
|
+
|
107
|
+
def initialize: (_Writer socket, HTTPResponse resp) -> void
|
108
|
+
|
109
|
+
def write: (_ToS buf) -> Integer
|
110
|
+
|
111
|
+
def <<: (*_ToS buf) -> self
|
112
|
+
end
|
113
|
+
|
114
|
+
# preserved for compatibility with some 3rd-party handlers
|
115
|
+
def _write_data: [T] (T socket, _ToS data) -> T
|
116
|
+
end
|
117
|
+
end
|
data/sig/https.rbs
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module WEBrick
|
2
|
+
class HTTPRequest
|
3
|
+
@client_cert_chain: Array[OpenSSL::X509::Certificate]
|
4
|
+
|
5
|
+
attr_reader cipher: [String, String, Integer, Integer]?
|
6
|
+
|
7
|
+
attr_reader server_cert: OpenSSL::X509::Certificate
|
8
|
+
|
9
|
+
attr_reader client_cert: OpenSSL::X509::Certificate?
|
10
|
+
|
11
|
+
alias orig_parse parse
|
12
|
+
|
13
|
+
def parse: (?(TCPSocket | OpenSSL::SSL::SSLSocket)? socket) -> void
|
14
|
+
| ...
|
15
|
+
|
16
|
+
alias orig_parse_uri parse_uri
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def parse_uri: (String str, ?::String scheme) -> URI::Generic
|
21
|
+
| ...
|
22
|
+
|
23
|
+
public
|
24
|
+
|
25
|
+
alias orig_meta_vars meta_vars
|
26
|
+
|
27
|
+
def meta_vars: () -> Hash[String, String]
|
28
|
+
| ...
|
29
|
+
end
|
30
|
+
|
31
|
+
class SNIRequest
|
32
|
+
attr_reader host: String?
|
33
|
+
|
34
|
+
attr_reader addr: [String, Integer, String, String]
|
35
|
+
|
36
|
+
attr_reader port: Integer
|
37
|
+
|
38
|
+
def initialize: (OpenSSL::SSL::SSLSocket sslsocket, ?String? hostname) -> void
|
39
|
+
end
|
40
|
+
|
41
|
+
class HTTPServer < ::WEBrick::GenericServer
|
42
|
+
def ssl_servername_callback: (OpenSSL::SSL::SSLSocket sslsocket, ?String? hostname) -> OpenSSL::SSL::SSLContext?
|
43
|
+
|
44
|
+
alias orig_virtual_host virtual_host
|
45
|
+
|
46
|
+
def virtual_host: (instance server) -> void
|
47
|
+
| ...
|
48
|
+
end
|
49
|
+
end
|
data/sig/httpserver.rbs
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
module WEBrick
|
2
|
+
class HTTPServerError < ServerError
|
3
|
+
end
|
4
|
+
|
5
|
+
class HTTPServer < ::WEBrick::GenericServer
|
6
|
+
@http_version: HTTPVersion
|
7
|
+
|
8
|
+
@mount_tab: MountTable
|
9
|
+
|
10
|
+
@virtual_hosts: Array[untyped]
|
11
|
+
|
12
|
+
def initialize: (?Hash[Symbol, untyped] config, ?Hash[Symbol, untyped] default) -> void
|
13
|
+
|
14
|
+
def run: (TCPSocket sock) -> void
|
15
|
+
|
16
|
+
def service: (HTTPRequest req, HTTPResponse res) -> void
|
17
|
+
|
18
|
+
def do_OPTIONS: (HTTPRequest req, HTTPResponse res) -> void
|
19
|
+
|
20
|
+
def mount: (String dir, singleton(HTTPServlet::AbstractServlet) servlet, *untyped options) -> void
|
21
|
+
|
22
|
+
def mount_proc: (String dir, ?HTTPServlet::ProcHandler::_Callable proc) -> void
|
23
|
+
| (String dir, ?nil proc) { (HTTPRequest, HTTPResponse) -> void } -> void
|
24
|
+
|
25
|
+
def unmount: (String dir) -> MountTable::value_type
|
26
|
+
|
27
|
+
alias umount unmount
|
28
|
+
|
29
|
+
def search_servlet: (String path) -> [singleton(HTTPServlet::AbstractServlet), Array[untyped], String, String]?
|
30
|
+
|
31
|
+
def virtual_host: (instance server) -> void
|
32
|
+
|
33
|
+
def lookup_server: (HTTPRequest req) -> instance?
|
34
|
+
|
35
|
+
def access_log: (Hash[Symbol, untyped] config, HTTPRequest req, HTTPResponse res) -> void
|
36
|
+
|
37
|
+
#
|
38
|
+
# Creates the HTTPRequest used when handling the HTTP
|
39
|
+
# request. Can be overridden by subclasses.
|
40
|
+
def create_request: (Hash[Symbol, untyped] with_webrick_config) -> HTTPRequest
|
41
|
+
|
42
|
+
#
|
43
|
+
# Creates the HTTPResponse used when handling the HTTP
|
44
|
+
# request. Can be overridden by subclasses.
|
45
|
+
def create_response: (Hash[Symbol, untyped] with_webrick_config) -> HTTPResponse
|
46
|
+
|
47
|
+
class MountTable
|
48
|
+
type value_type = [singleton(HTTPServlet::AbstractServlet), Array[untyped]]
|
49
|
+
|
50
|
+
@tab: Hash[String, value_type]
|
51
|
+
|
52
|
+
@scanner: Regexp
|
53
|
+
|
54
|
+
def initialize: () -> void
|
55
|
+
|
56
|
+
def []: (String dir) -> value_type
|
57
|
+
|
58
|
+
def []=: (String dir, value_type val) -> value_type
|
59
|
+
|
60
|
+
def delete: (String dir) -> value_type
|
61
|
+
|
62
|
+
def scan: (String path) -> [String, String]
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def compile: () -> void
|
67
|
+
|
68
|
+
def normalize: (String dir) -> String
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module WEBrick
|
2
|
+
module HTTPServlet
|
3
|
+
class HTTPServletError < StandardError
|
4
|
+
end
|
5
|
+
|
6
|
+
class AbstractServlet
|
7
|
+
@server: HTTPServer
|
8
|
+
|
9
|
+
interface _Config
|
10
|
+
def []: (Symbol) -> untyped
|
11
|
+
end
|
12
|
+
|
13
|
+
@config: _Config
|
14
|
+
|
15
|
+
@logger: Log
|
16
|
+
|
17
|
+
@options: untyped # Array[untyped] causes RBS::InstanceVariableTypeError
|
18
|
+
|
19
|
+
def self.get_instance: (HTTPServer server, *untyped options) -> instance
|
20
|
+
|
21
|
+
def initialize: (HTTPServer server, *untyped options) -> void
|
22
|
+
|
23
|
+
def service: (HTTPRequest req, HTTPResponse res) -> void
|
24
|
+
|
25
|
+
def do_GET: (HTTPRequest req, HTTPResponse res) -> bot
|
26
|
+
|
27
|
+
def do_HEAD: (HTTPRequest req, HTTPResponse res) -> bot
|
28
|
+
|
29
|
+
def do_OPTIONS: (HTTPRequest req, HTTPResponse res) -> void
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def redirect_to_directory_uri: (HTTPRequest req, HTTPResponse res) -> void
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module WEBrick
|
2
|
+
module HTTPServlet
|
3
|
+
class CGIHandler < AbstractServlet
|
4
|
+
@script_filename: String
|
5
|
+
|
6
|
+
@tempdir: String?
|
7
|
+
|
8
|
+
@cgicmd: Array[String] | String
|
9
|
+
|
10
|
+
Ruby: String
|
11
|
+
|
12
|
+
CGIRunner: String
|
13
|
+
|
14
|
+
CGIRunnerArray: [String, String]
|
15
|
+
|
16
|
+
def initialize: (HTTPServer server, String name) -> void
|
17
|
+
|
18
|
+
def do_GET: (HTTPRequest req, HTTPResponse res) -> void
|
19
|
+
|
20
|
+
alias do_POST do_GET
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module WEBrick
|
2
|
+
module HTTPServlet
|
3
|
+
class ERBHandler < AbstractServlet
|
4
|
+
@script_filename: String
|
5
|
+
|
6
|
+
def initialize: (HTTPServer server, String name) -> void
|
7
|
+
|
8
|
+
def do_GET: (HTTPRequest req, HTTPResponse res) -> void
|
9
|
+
|
10
|
+
alias do_POST do_GET
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def evaluate: (ERB erb, HTTPRequest servlet_request, HTTPResponse servlet_response) -> String
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|