webrick 1.8.1 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -0,0 +1,169 @@
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
+ @form_data: nil
12
+
13
+ @body: String
14
+
15
+ @remaining_size: Integer?
16
+
17
+ @socket: TCPSocket?
18
+
19
+ @forwarded_proto: String?
20
+
21
+ @host: String?
22
+
23
+ @port: Integer?
24
+
25
+ @body_tmp: Array[String]
26
+
27
+ @body_rd: Fiber
28
+
29
+ @request_bytes: Integer
30
+
31
+ @forwarded_server: String?
32
+
33
+ @forwarded_host: String?
34
+
35
+ @forwarded_port: Integer?
36
+
37
+ @forwarded_for: String?
38
+
39
+ BODY_CONTAINABLE_METHODS: Array[String]
40
+
41
+ attr_reader request_line: String?
42
+
43
+ attr_reader request_method: String?
44
+
45
+ attr_reader unparsed_uri: String?
46
+
47
+ attr_reader http_version: HTTPVersion?
48
+
49
+ attr_reader request_uri: URI::Generic?
50
+
51
+ attr_reader path: String?
52
+
53
+ attr_accessor script_name: String?
54
+
55
+ attr_accessor path_info: String?
56
+
57
+ attr_accessor query_string: String?
58
+
59
+ attr_reader raw_header: Array[String]
60
+
61
+ attr_reader header: Hash[String, Array[String]]?
62
+
63
+ attr_reader cookies: Array[Cookie]
64
+
65
+ attr_reader accept: Array[String]
66
+
67
+ attr_reader accept_charset: Array[String]
68
+
69
+ attr_reader accept_encoding: Array[String]
70
+
71
+ attr_reader accept_language: Array[String]
72
+
73
+ attr_accessor user: String?
74
+
75
+ attr_reader addr: ([String, Integer, String, String] | [])?
76
+
77
+ attr_reader peeraddr: ([String, Integer, String, String] | [])?
78
+
79
+ attr_reader attributes: Hash[untyped, untyped]
80
+
81
+ attr_reader keep_alive: bool
82
+
83
+ attr_reader request_time: Time?
84
+
85
+ def initialize: (Hash[Symbol, untyped] config) -> void
86
+
87
+ def parse: (?TCPSocket? socket) -> void
88
+
89
+ def continue: () -> void
90
+
91
+ type body_chunk_block = ^(String body_chunk) -> void
92
+
93
+ def body: () ?{ (String body_chunk) -> void } -> String
94
+
95
+ def body_reader: () -> self
96
+
97
+ # for IO.copy_stream.
98
+ def readpartial: (Integer size, ?String buf) -> String
99
+
100
+ def query: () -> Hash[String, HTTPUtils::FormData]
101
+
102
+ def content_length: () -> Integer
103
+
104
+ def content_type: () -> String?
105
+
106
+ def []: (String header_name) -> String?
107
+
108
+ def each: [T] () { (String, String) -> T } -> T?
109
+
110
+ def host: () -> String?
111
+
112
+ def port: () -> Integer?
113
+
114
+ def server_name: () -> String?
115
+
116
+ def remote_ip: () -> String?
117
+
118
+ def ssl?: () -> bool
119
+
120
+ def keep_alive?: () -> bool
121
+
122
+ def to_s: () -> String
123
+
124
+ def fixup: () -> void
125
+
126
+ def meta_vars: () -> Hash[String, String]
127
+
128
+ private
129
+
130
+ MAX_URI_LENGTH: Integer
131
+
132
+ # same as Mongrel, Thin and Puma
133
+ MAX_HEADER_LENGTH: Integer
134
+
135
+ def read_request_line: (IO socket) -> void
136
+
137
+ def read_header: (IO socket) -> void
138
+
139
+ def parse_uri: (String str, ?String scheme) -> URI::Generic
140
+
141
+ HOST_PATTERN: Regexp
142
+
143
+ def parse_host_request_line: (String host) -> [String, String]
144
+
145
+ def read_body: (IO socket, body_chunk_block block) -> String
146
+ | (nil socket, top block) -> nil
147
+
148
+ def read_chunk_size: (IO socket) -> [Integer, String?]
149
+
150
+ def read_chunked: (IO socket, body_chunk_block block) -> void
151
+
152
+ def _read_data: (IO io, Symbol method, *untyped arg) -> String?
153
+
154
+ def read_line: (IO io, ?Integer size) -> String?
155
+
156
+ def read_data: (IO io, Integer size) -> String?
157
+
158
+ def parse_query: () -> void
159
+
160
+ PrivateNetworkRegexp: Regexp
161
+
162
+ # It's said that all X-Forwarded-* headers will contain more than one
163
+ # (comma-separated) value if the original request already contained one of
164
+ # these headers. Since we could use these values as Host header, we choose
165
+ # the initial(first) value. (apr_table_mergen() adds new value after the
166
+ # existing value with ", " prefix)
167
+ def setup_forwarded_info: () -> void
168
+ end
169
+ 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
@@ -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,3 @@
1
+ class Object
2
+ def sysread: (IO io, Integer size) -> String
3
+ 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
@@ -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