webrick 1.3.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of webrick might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +63 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/webrick/accesslog.rb +9 -1
- data/lib/webrick/cgi.rb +58 -5
- data/lib/webrick/compat.rb +2 -1
- data/lib/webrick/config.rb +47 -10
- data/lib/webrick/cookie.rb +69 -7
- data/lib/webrick/htmlutils.rb +4 -2
- data/lib/webrick/httpauth/authenticator.rb +13 -8
- data/lib/webrick/httpauth/basicauth.rb +16 -8
- data/lib/webrick/httpauth/digestauth.rb +35 -32
- data/lib/webrick/httpauth/htdigest.rb +12 -8
- data/lib/webrick/httpauth/htgroup.rb +10 -6
- data/lib/webrick/httpauth/htpasswd.rb +46 -9
- data/lib/webrick/httpauth/userdb.rb +1 -0
- data/lib/webrick/httpauth.rb +6 -5
- data/lib/webrick/httpproxy.rb +93 -48
- data/lib/webrick/httprequest.rb +192 -27
- data/lib/webrick/httpresponse.rb +221 -70
- data/lib/webrick/https.rb +90 -2
- data/lib/webrick/httpserver.rb +45 -15
- data/lib/webrick/httpservlet/abstract.rb +5 -6
- data/lib/webrick/httpservlet/cgi_runner.rb +3 -2
- data/lib/webrick/httpservlet/cgihandler.rb +22 -10
- data/lib/webrick/httpservlet/erbhandler.rb +4 -3
- data/lib/webrick/httpservlet/filehandler.rb +136 -65
- data/lib/webrick/httpservlet/prochandler.rb +15 -1
- data/lib/webrick/httpservlet.rb +6 -5
- data/lib/webrick/httpstatus.rb +24 -14
- data/lib/webrick/httputils.rb +133 -13
- data/lib/webrick/httpversion.rb +28 -1
- data/lib/webrick/log.rb +25 -5
- data/lib/webrick/server.rb +234 -74
- data/lib/webrick/ssl.rb +100 -12
- data/lib/webrick/utils.rb +98 -69
- data/lib/webrick/version.rb +6 -1
- data/lib/webrick.rb +7 -7
- data/webrick.gemspec +76 -0
- metadata +70 -69
- data/README.txt +0 -21
- data/sample/webrick/demo-app.rb +0 -66
- data/sample/webrick/demo-multipart.cgi +0 -12
- data/sample/webrick/demo-servlet.rb +0 -6
- data/sample/webrick/demo-urlencoded.cgi +0 -12
- data/sample/webrick/hello.cgi +0 -11
- data/sample/webrick/hello.rb +0 -8
- data/sample/webrick/httpd.rb +0 -23
- data/sample/webrick/httpproxy.rb +0 -25
- data/sample/webrick/httpsd.rb +0 -33
- data/test/openssl/utils.rb +0 -313
- data/test/ruby/envutil.rb +0 -208
- data/test/webrick/test_cgi.rb +0 -134
- data/test/webrick/test_cookie.rb +0 -131
- data/test/webrick/test_filehandler.rb +0 -285
- data/test/webrick/test_httpauth.rb +0 -167
- data/test/webrick/test_httpproxy.rb +0 -282
- data/test/webrick/test_httprequest.rb +0 -411
- data/test/webrick/test_httpresponse.rb +0 -49
- data/test/webrick/test_httpserver.rb +0 -305
- data/test/webrick/test_httputils.rb +0 -96
- data/test/webrick/test_httpversion.rb +0 -40
- data/test/webrick/test_server.rb +0 -67
- data/test/webrick/test_utils.rb +0 -64
- data/test/webrick/utils.rb +0 -58
- data/test/webrick/webrick.cgi +0 -36
- data/test/webrick/webrick_long_filename.cgi +0 -36
data/lib/webrick/utils.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: false
|
1
2
|
#
|
2
3
|
# utils.rb -- Miscellaneous utilities
|
3
4
|
#
|
@@ -9,45 +10,34 @@
|
|
9
10
|
# $IPR: utils.rb,v 1.10 2003/02/16 22:22:54 gotoyuzo Exp $
|
10
11
|
|
11
12
|
require 'socket'
|
12
|
-
require '
|
13
|
-
|
14
|
-
require 'etc'
|
15
|
-
rescue LoadError
|
16
|
-
nil
|
17
|
-
end
|
13
|
+
require 'io/nonblock'
|
14
|
+
require 'etc'
|
18
15
|
|
19
16
|
module WEBrick
|
20
17
|
module Utils
|
21
18
|
##
|
22
19
|
# Sets IO operations on +io+ to be non-blocking
|
23
20
|
def set_non_blocking(io)
|
24
|
-
|
25
|
-
if defined?(Fcntl::F_GETFL)
|
26
|
-
flag |= io.fcntl(Fcntl::F_GETFL)
|
27
|
-
end
|
28
|
-
io.fcntl(Fcntl::F_SETFL, flag)
|
21
|
+
io.nonblock = true if io.respond_to?(:nonblock=)
|
29
22
|
end
|
30
23
|
module_function :set_non_blocking
|
31
24
|
|
32
25
|
##
|
33
26
|
# Sets the close on exec flag for +io+
|
34
27
|
def set_close_on_exec(io)
|
35
|
-
if
|
36
|
-
io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
37
|
-
end
|
28
|
+
io.close_on_exec = true if io.respond_to?(:close_on_exec=)
|
38
29
|
end
|
39
30
|
module_function :set_close_on_exec
|
40
31
|
|
41
32
|
##
|
42
33
|
# Changes the process's uid and gid to the ones of +user+
|
43
34
|
def su(user)
|
44
|
-
if
|
45
|
-
pw = Etc.getpwnam(user)
|
35
|
+
if pw = Etc.getpwnam(user)
|
46
36
|
Process::initgroups(user, pw.gid)
|
47
37
|
Process::Sys::setgid(pw.gid)
|
48
38
|
Process::Sys::setuid(pw.uid)
|
49
39
|
else
|
50
|
-
warn("WEBrick::Utils::su doesn't work on this platform")
|
40
|
+
warn("WEBrick::Utils::su doesn't work on this platform", uplevel: 1)
|
51
41
|
end
|
52
42
|
end
|
53
43
|
module_function :su
|
@@ -68,30 +58,17 @@ module WEBrick
|
|
68
58
|
# Creates TCP server sockets bound to +address+:+port+ and returns them.
|
69
59
|
#
|
70
60
|
# It will create IPV4 and IPV6 sockets on all interfaces.
|
71
|
-
def create_listeners(address, port
|
61
|
+
def create_listeners(address, port)
|
72
62
|
unless port
|
73
63
|
raise ArgumentError, "must specify port"
|
74
64
|
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
sockets = []
|
82
|
-
res.each{|ai|
|
83
|
-
begin
|
84
|
-
logger.debug("TCPServer.new(#{ai[3]}, #{port})") if logger
|
85
|
-
sock = TCPServer.new(ai[3], port)
|
86
|
-
port = sock.addr[1] if port == 0
|
87
|
-
Utils::set_close_on_exec(sock)
|
88
|
-
sockets << sock
|
89
|
-
rescue => ex
|
90
|
-
logger.warn("TCPServer Error: #{ex}") if logger
|
91
|
-
last_error = ex
|
92
|
-
end
|
65
|
+
sockets = Socket.tcp_server_sockets(address, port)
|
66
|
+
sockets = sockets.map {|s|
|
67
|
+
s.autoclose = false
|
68
|
+
ts = TCPServer.for_fd(s.fileno)
|
69
|
+
s.close
|
70
|
+
ts
|
93
71
|
}
|
94
|
-
raise last_error if sockets.empty?
|
95
72
|
return sockets
|
96
73
|
end
|
97
74
|
module_function :create_listeners
|
@@ -114,7 +91,6 @@ module WEBrick
|
|
114
91
|
|
115
92
|
###########
|
116
93
|
|
117
|
-
require "thread"
|
118
94
|
require "timeout"
|
119
95
|
require "singleton"
|
120
96
|
|
@@ -149,7 +125,7 @@ module WEBrick
|
|
149
125
|
|
150
126
|
##
|
151
127
|
# Mutex used to synchronize access across threads
|
152
|
-
TimeoutMutex = Mutex.new # :nodoc:
|
128
|
+
TimeoutMutex = Thread::Mutex.new # :nodoc:
|
153
129
|
|
154
130
|
##
|
155
131
|
# Registers a new timeout handler
|
@@ -157,43 +133,82 @@ module WEBrick
|
|
157
133
|
# +time+:: Timeout in seconds
|
158
134
|
# +exception+:: Exception to raise when timeout elapsed
|
159
135
|
def TimeoutHandler.register(seconds, exception)
|
160
|
-
|
161
|
-
|
162
|
-
}
|
136
|
+
at = Process.clock_gettime(Process::CLOCK_MONOTONIC) + seconds
|
137
|
+
instance.register(Thread.current, at, exception)
|
163
138
|
end
|
164
139
|
|
165
140
|
##
|
166
141
|
# Cancels the timeout handler +id+
|
167
142
|
def TimeoutHandler.cancel(id)
|
143
|
+
instance.cancel(Thread.current, id)
|
144
|
+
end
|
145
|
+
|
146
|
+
def self.terminate
|
147
|
+
instance.terminate
|
148
|
+
end
|
149
|
+
|
150
|
+
##
|
151
|
+
# Creates a new TimeoutHandler. You should use ::register and ::cancel
|
152
|
+
# instead of creating the timeout handler directly.
|
153
|
+
def initialize
|
168
154
|
TimeoutMutex.synchronize{
|
169
|
-
|
155
|
+
@timeout_info = Hash.new
|
170
156
|
}
|
157
|
+
@queue = Thread::Queue.new
|
158
|
+
@watcher = nil
|
171
159
|
end
|
172
160
|
|
173
|
-
|
174
|
-
|
175
|
-
|
161
|
+
# :nodoc:
|
162
|
+
private \
|
163
|
+
def watch
|
164
|
+
to_interrupt = []
|
176
165
|
while true
|
177
|
-
now =
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
166
|
+
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
167
|
+
wakeup = nil
|
168
|
+
to_interrupt.clear
|
169
|
+
TimeoutMutex.synchronize{
|
170
|
+
@timeout_info.each {|thread, ary|
|
171
|
+
next unless ary
|
172
|
+
ary.each{|info|
|
173
|
+
time, exception = *info
|
174
|
+
if time < now
|
175
|
+
to_interrupt.push [thread, info.object_id, exception]
|
176
|
+
elsif !wakeup || time < wakeup
|
177
|
+
wakeup = time
|
178
|
+
end
|
179
|
+
}
|
182
180
|
}
|
183
181
|
}
|
184
|
-
|
182
|
+
to_interrupt.each {|arg| interrupt(*arg)}
|
183
|
+
if !wakeup
|
184
|
+
@queue.pop
|
185
|
+
elsif (wakeup -= now) > 0
|
186
|
+
begin
|
187
|
+
(th = Thread.start {@queue.pop}).join(wakeup)
|
188
|
+
ensure
|
189
|
+
th&.kill&.join
|
190
|
+
end
|
191
|
+
end
|
192
|
+
@queue.clear
|
185
193
|
end
|
186
|
-
|
187
|
-
|
194
|
+
end
|
195
|
+
|
196
|
+
# :nodoc:
|
197
|
+
private \
|
198
|
+
def watcher
|
199
|
+
(w = @watcher)&.alive? and return w # usual case
|
200
|
+
TimeoutMutex.synchronize{
|
201
|
+
(w = @watcher)&.alive? and next w # pathological check
|
202
|
+
@watcher = Thread.start(&method(:watch))
|
203
|
+
}
|
204
|
+
end
|
188
205
|
|
189
206
|
##
|
190
207
|
# Interrupts the timeout handler +id+ and raises +exception+
|
191
208
|
def interrupt(thread, id, exception)
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
end
|
196
|
-
}
|
209
|
+
if cancel(thread, id) && thread.alive?
|
210
|
+
thread.raise(exception, "execution timeout")
|
211
|
+
end
|
197
212
|
end
|
198
213
|
|
199
214
|
##
|
@@ -202,22 +217,36 @@ module WEBrick
|
|
202
217
|
# +time+:: Timeout in seconds
|
203
218
|
# +exception+:: Exception to raise when timeout elapsed
|
204
219
|
def register(thread, time, exception)
|
205
|
-
|
206
|
-
|
207
|
-
|
220
|
+
info = nil
|
221
|
+
TimeoutMutex.synchronize{
|
222
|
+
(@timeout_info[thread] ||= []) << (info = [time, exception])
|
223
|
+
}
|
224
|
+
@queue.push nil
|
225
|
+
watcher
|
226
|
+
return info.object_id
|
208
227
|
end
|
209
228
|
|
210
229
|
##
|
211
230
|
# Cancels the timeout handler +id+
|
212
231
|
def cancel(thread, id)
|
213
|
-
|
214
|
-
ary
|
215
|
-
|
216
|
-
|
232
|
+
TimeoutMutex.synchronize{
|
233
|
+
if ary = @timeout_info[thread]
|
234
|
+
ary.delete_if{|info| info.object_id == id }
|
235
|
+
if ary.empty?
|
236
|
+
@timeout_info.delete(thread)
|
237
|
+
end
|
238
|
+
return true
|
217
239
|
end
|
218
|
-
return
|
219
|
-
|
220
|
-
|
240
|
+
return false
|
241
|
+
}
|
242
|
+
end
|
243
|
+
|
244
|
+
##
|
245
|
+
def terminate
|
246
|
+
TimeoutMutex.synchronize{
|
247
|
+
@timeout_info.clear
|
248
|
+
@watcher&.kill&.join
|
249
|
+
}
|
221
250
|
end
|
222
251
|
end
|
223
252
|
|
data/lib/webrick/version.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: false
|
1
2
|
#--
|
2
3
|
# version.rb -- version and release date
|
3
4
|
#
|
@@ -9,5 +10,9 @@
|
|
9
10
|
# $IPR: version.rb,v 1.74 2003/07/22 19:20:43 gotoyuzo Exp $
|
10
11
|
|
11
12
|
module WEBrick
|
12
|
-
|
13
|
+
|
14
|
+
##
|
15
|
+
# The WEBrick version
|
16
|
+
|
17
|
+
VERSION = "1.5.0"
|
13
18
|
end
|
data/lib/webrick.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: false
|
1
2
|
##
|
2
3
|
# = WEB server toolkit.
|
3
4
|
#
|
@@ -6,9 +7,9 @@
|
|
6
7
|
# logging of both server operations and HTTP access. WEBrick supports both
|
7
8
|
# basic and digest authentication in addition to algorithms not in RFC 2617.
|
8
9
|
#
|
9
|
-
# A WEBrick
|
10
|
+
# A WEBrick server can be composed of multiple WEBrick servers or servlets to
|
10
11
|
# provide differing behavior on a per-host or per-path basis. WEBrick
|
11
|
-
# includes servlets for handling CGI scripts,
|
12
|
+
# includes servlets for handling CGI scripts, ERB pages, Ruby blocks and
|
12
13
|
# directory listings.
|
13
14
|
#
|
14
15
|
# WEBrick also includes tools for daemonizing a process and starting a process
|
@@ -42,7 +43,7 @@
|
|
42
43
|
# res.body = 'Hello, world!'
|
43
44
|
# end
|
44
45
|
#
|
45
|
-
# Remember that
|
46
|
+
# Remember that +server.mount_proc+ must precede +server.start+.
|
46
47
|
#
|
47
48
|
# == Servlets
|
48
49
|
#
|
@@ -129,9 +130,8 @@
|
|
129
130
|
#
|
130
131
|
# trap 'INT' do proxy.shutdown end
|
131
132
|
#
|
132
|
-
#
|
133
|
-
#
|
134
|
-
# respone after the remote content has been fetched.
|
133
|
+
# See WEBrick::HTTPProxy for further details including modifying proxied
|
134
|
+
# responses.
|
135
135
|
#
|
136
136
|
# == Basic and Digest authentication
|
137
137
|
#
|
@@ -212,7 +212,7 @@ require 'webrick/version.rb'
|
|
212
212
|
require 'webrick/config.rb'
|
213
213
|
require 'webrick/log.rb'
|
214
214
|
require 'webrick/server.rb'
|
215
|
-
|
215
|
+
require_relative 'webrick/utils.rb'
|
216
216
|
require 'webrick/accesslog'
|
217
217
|
|
218
218
|
require 'webrick/htmlutils.rb'
|
data/webrick.gemspec
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
begin
|
3
|
+
require_relative 'lib/webrick/version'
|
4
|
+
rescue LoadError
|
5
|
+
# for Ruby core repository
|
6
|
+
require_relative 'version'
|
7
|
+
end
|
8
|
+
|
9
|
+
Gem::Specification.new do |s|
|
10
|
+
s.name = "webrick"
|
11
|
+
s.version = WEBrick::VERSION
|
12
|
+
s.summary = "HTTP server toolkit"
|
13
|
+
s.description = "WEBrick is an HTTP server toolkit that can be configured as an HTTPS server, a proxy server, and a virtual-host server."
|
14
|
+
|
15
|
+
s.require_path = %w{lib}
|
16
|
+
s.files = [
|
17
|
+
"Gemfile",
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md",
|
20
|
+
"Rakefile",
|
21
|
+
"bin/console",
|
22
|
+
"bin/setup",
|
23
|
+
"lib/webrick.rb",
|
24
|
+
"lib/webrick/accesslog.rb",
|
25
|
+
"lib/webrick/cgi.rb",
|
26
|
+
"lib/webrick/compat.rb",
|
27
|
+
"lib/webrick/config.rb",
|
28
|
+
"lib/webrick/cookie.rb",
|
29
|
+
"lib/webrick/htmlutils.rb",
|
30
|
+
"lib/webrick/httpauth.rb",
|
31
|
+
"lib/webrick/httpauth/authenticator.rb",
|
32
|
+
"lib/webrick/httpauth/basicauth.rb",
|
33
|
+
"lib/webrick/httpauth/digestauth.rb",
|
34
|
+
"lib/webrick/httpauth/htdigest.rb",
|
35
|
+
"lib/webrick/httpauth/htgroup.rb",
|
36
|
+
"lib/webrick/httpauth/htpasswd.rb",
|
37
|
+
"lib/webrick/httpauth/userdb.rb",
|
38
|
+
"lib/webrick/httpproxy.rb",
|
39
|
+
"lib/webrick/httprequest.rb",
|
40
|
+
"lib/webrick/httpresponse.rb",
|
41
|
+
"lib/webrick/https.rb",
|
42
|
+
"lib/webrick/httpserver.rb",
|
43
|
+
"lib/webrick/httpservlet.rb",
|
44
|
+
"lib/webrick/httpservlet/abstract.rb",
|
45
|
+
"lib/webrick/httpservlet/cgi_runner.rb",
|
46
|
+
"lib/webrick/httpservlet/cgihandler.rb",
|
47
|
+
"lib/webrick/httpservlet/erbhandler.rb",
|
48
|
+
"lib/webrick/httpservlet/filehandler.rb",
|
49
|
+
"lib/webrick/httpservlet/prochandler.rb",
|
50
|
+
"lib/webrick/httpstatus.rb",
|
51
|
+
"lib/webrick/httputils.rb",
|
52
|
+
"lib/webrick/httpversion.rb",
|
53
|
+
"lib/webrick/log.rb",
|
54
|
+
"lib/webrick/server.rb",
|
55
|
+
"lib/webrick/ssl.rb",
|
56
|
+
"lib/webrick/utils.rb",
|
57
|
+
"lib/webrick/version.rb",
|
58
|
+
"webrick.gemspec",
|
59
|
+
]
|
60
|
+
s.required_ruby_version = ">= 2.3.0"
|
61
|
+
|
62
|
+
s.authors = ["TAKAHASHI Masayoshi", "GOTOU YUUZOU", "Eric Wong"]
|
63
|
+
s.email = [nil, nil, 'normal@ruby-lang.org']
|
64
|
+
s.homepage = "https://www.ruby-lang.org"
|
65
|
+
s.license = "BSD-2-Clause"
|
66
|
+
|
67
|
+
if s.respond_to?(:metadata=)
|
68
|
+
s.metadata = {
|
69
|
+
"bug_tracker_uri" => "https://bugs.ruby-lang.org/projects/ruby-trunk/issues",
|
70
|
+
"homepage_uri" => "https://www.ruby-lang.org",
|
71
|
+
"source_code_uri" => "https://git.ruby-lang.org/ruby.git/"
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
s.add_development_dependency "rake"
|
76
|
+
end
|
metadata
CHANGED
@@ -1,106 +1,107 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webrick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.5.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
-
|
7
|
+
- TAKAHASHI Masayoshi
|
8
|
+
- GOTOU YUUZOU
|
9
|
+
- Eric Wong
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
|
15
|
-
|
13
|
+
date: 2019-10-04 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
description: WEBrick is an HTTP server toolkit that can be configured as an HTTPS
|
30
|
+
server, a proxy server, and a virtual-host server.
|
31
|
+
email:
|
32
|
+
-
|
33
|
+
-
|
34
|
+
- normal@ruby-lang.org
|
16
35
|
executables: []
|
17
36
|
extensions: []
|
18
37
|
extra_rdoc_files: []
|
19
38
|
files:
|
20
|
-
-
|
21
|
-
-
|
22
|
-
-
|
23
|
-
-
|
24
|
-
-
|
25
|
-
-
|
26
|
-
- lib/webrick
|
27
|
-
- lib/webrick/compat.rb
|
28
|
-
- lib/webrick/httpresponse.rb
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- bin/console
|
44
|
+
- bin/setup
|
45
|
+
- lib/webrick.rb
|
29
46
|
- lib/webrick/accesslog.rb
|
30
|
-
- lib/webrick/httpversion.rb
|
31
|
-
- lib/webrick/utils.rb
|
32
|
-
- lib/webrick/version.rb
|
33
|
-
- lib/webrick/httprequest.rb
|
34
|
-
- lib/webrick/httpauth.rb
|
35
|
-
- lib/webrick/server.rb
|
36
|
-
- lib/webrick/httpproxy.rb
|
37
|
-
- lib/webrick/ssl.rb
|
38
47
|
- lib/webrick/cgi.rb
|
39
|
-
- lib/webrick/
|
40
|
-
- lib/webrick/
|
41
|
-
- lib/webrick/httpserver.rb
|
48
|
+
- lib/webrick/compat.rb
|
49
|
+
- lib/webrick/config.rb
|
42
50
|
- lib/webrick/cookie.rb
|
43
|
-
- lib/webrick/
|
51
|
+
- lib/webrick/htmlutils.rb
|
52
|
+
- lib/webrick/httpauth.rb
|
53
|
+
- lib/webrick/httpauth/authenticator.rb
|
44
54
|
- lib/webrick/httpauth/basicauth.rb
|
45
55
|
- lib/webrick/httpauth/digestauth.rb
|
46
|
-
- lib/webrick/httpauth/authenticator.rb
|
47
56
|
- lib/webrick/httpauth/htdigest.rb
|
48
57
|
- lib/webrick/httpauth/htgroup.rb
|
49
58
|
- lib/webrick/httpauth/htpasswd.rb
|
50
59
|
- lib/webrick/httpauth/userdb.rb
|
51
|
-
- lib/webrick/
|
60
|
+
- lib/webrick/httpproxy.rb
|
61
|
+
- lib/webrick/httprequest.rb
|
62
|
+
- lib/webrick/httpresponse.rb
|
63
|
+
- lib/webrick/https.rb
|
64
|
+
- lib/webrick/httpserver.rb
|
52
65
|
- lib/webrick/httpservlet.rb
|
66
|
+
- lib/webrick/httpservlet/abstract.rb
|
67
|
+
- lib/webrick/httpservlet/cgi_runner.rb
|
68
|
+
- lib/webrick/httpservlet/cgihandler.rb
|
69
|
+
- lib/webrick/httpservlet/erbhandler.rb
|
70
|
+
- lib/webrick/httpservlet/filehandler.rb
|
71
|
+
- lib/webrick/httpservlet/prochandler.rb
|
72
|
+
- lib/webrick/httpstatus.rb
|
73
|
+
- lib/webrick/httputils.rb
|
74
|
+
- lib/webrick/httpversion.rb
|
53
75
|
- lib/webrick/log.rb
|
54
|
-
- lib/webrick.rb
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
|
60
|
-
|
61
|
-
-
|
62
|
-
|
63
|
-
-
|
64
|
-
|
65
|
-
-
|
66
|
-
- test/webrick/test_httpproxy.rb
|
67
|
-
- test/webrick/test_cookie.rb
|
68
|
-
- test/webrick/test_server.rb
|
69
|
-
- test/webrick/test_httpresponse.rb
|
70
|
-
- test/webrick/test_utils.rb
|
71
|
-
- test/webrick/test_httpserver.rb
|
72
|
-
- test/webrick/test_httprequest.rb
|
73
|
-
- test/webrick/test_httpversion.rb
|
74
|
-
- test/webrick/webrick.cgi
|
75
|
-
- test/webrick/test_httpauth.rb
|
76
|
-
- test/webrick/test_cgi.rb
|
77
|
-
- test/webrick/test_httputils.rb
|
78
|
-
- test/webrick/test_filehandler.rb
|
79
|
-
- test/ruby/envutil.rb
|
80
|
-
- test/openssl/utils.rb
|
81
|
-
- README.txt
|
82
|
-
homepage: http://github.com/nahi/webrick
|
83
|
-
licenses: []
|
76
|
+
- lib/webrick/server.rb
|
77
|
+
- lib/webrick/ssl.rb
|
78
|
+
- lib/webrick/utils.rb
|
79
|
+
- lib/webrick/version.rb
|
80
|
+
- webrick.gemspec
|
81
|
+
homepage: https://www.ruby-lang.org
|
82
|
+
licenses:
|
83
|
+
- BSD-2-Clause
|
84
|
+
metadata:
|
85
|
+
bug_tracker_uri: https://bugs.ruby-lang.org/projects/ruby-trunk/issues
|
86
|
+
homepage_uri: https://www.ruby-lang.org
|
87
|
+
source_code_uri: https://git.ruby-lang.org/ruby.git/
|
84
88
|
post_install_message:
|
85
89
|
rdoc_options: []
|
86
90
|
require_paths:
|
87
91
|
- lib
|
88
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
93
|
requirements:
|
91
|
-
- -
|
94
|
+
- - ">="
|
92
95
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
96
|
+
version: 2.3.0
|
94
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
98
|
requirements:
|
97
|
-
- -
|
99
|
+
- - ">="
|
98
100
|
- !ruby/object:Gem::Version
|
99
101
|
version: '0'
|
100
102
|
requirements: []
|
101
|
-
|
102
|
-
rubygems_version: 1.8.11
|
103
|
+
rubygems_version: 3.0.3
|
103
104
|
signing_key:
|
104
|
-
specification_version:
|
105
|
-
summary:
|
105
|
+
specification_version: 4
|
106
|
+
summary: HTTP server toolkit
|
106
107
|
test_files: []
|
data/README.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
= WEB server toolkit.
|
2
|
-
|
3
|
-
WEBrick is an HTTP server toolkit that can be configured as an HTTPS server,
|
4
|
-
a proxy server, and a virtual-host server. WEBrick features complete
|
5
|
-
logging of both server operations and HTTP access. WEBrick supports both
|
6
|
-
basic and digest authentication in addition to algorithms not in RFC 2617.
|
7
|
-
|
8
|
-
A WEBrick servers can be composed of multiple WEBrick servers or servlets to
|
9
|
-
provide differing behavior on a per-host or per-path basis. WEBrick
|
10
|
-
includes servlets for handling CGI scripts, ERb pages, ruby blocks and
|
11
|
-
directory listings.
|
12
|
-
|
13
|
-
WEBrick also includes tools for daemonizing a process and starting a process
|
14
|
-
at a higher privilege level and dropping permissions.
|
15
|
-
|
16
|
-
== Copyright
|
17
|
-
|
18
|
-
Author: IPR -- Internet Programming with Ruby -- writers
|
19
|
-
|
20
|
-
Copyright (c) 2000 TAKAHASHI Masayoshi, GOTOU YUUZOU
|
21
|
-
Copyright (c) 2002 Internet Programming with Ruby writers. All rights reserved.
|
data/sample/webrick/demo-app.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require "pp"
|
2
|
-
|
3
|
-
module DemoApplication
|
4
|
-
def initialize(config, enctype)
|
5
|
-
super
|
6
|
-
@enctype = enctype
|
7
|
-
end
|
8
|
-
|
9
|
-
def do_GET(req, res)
|
10
|
-
if req.path_info != "/"
|
11
|
-
res.set_redirect(WEBrick::HTTPStatus::Found, req.script_name + "/")
|
12
|
-
end
|
13
|
-
res.body =<<-_end_of_html_
|
14
|
-
<HTML>
|
15
|
-
<FORM method="POST" enctype=#{@enctype}>
|
16
|
-
text: <INPUT type="text" name="text"><BR>
|
17
|
-
file: <INPUT type="file" name="file"><BR>
|
18
|
-
check:
|
19
|
-
<INPUT type="checkbox" name="check" value="a">a,
|
20
|
-
<INPUT type="checkbox" name="check" value="b">b,
|
21
|
-
<INPUT type="checkbox" name="check" value="c">c,
|
22
|
-
<BR>
|
23
|
-
<INPUT type="submit">
|
24
|
-
</FORM>
|
25
|
-
</HTML>
|
26
|
-
_end_of_html_
|
27
|
-
res['content-type'] = 'text/html; charset=iso-8859-1'
|
28
|
-
end
|
29
|
-
|
30
|
-
def do_POST(req, res)
|
31
|
-
if req["content-length"].to_i > 1024*10
|
32
|
-
raise WEBrick::HTTPStatus::Forbidden, "file size too large"
|
33
|
-
end
|
34
|
-
res.body =<<-_end_of_html_
|
35
|
-
<HTML>
|
36
|
-
<H2>Query Parameters</H2>
|
37
|
-
#{display_query(req.query)}
|
38
|
-
<A href="#{req.path}">return</A>
|
39
|
-
<H2>Request</H2>
|
40
|
-
<PRE>#{WEBrick::HTMLUtils::escape(PP::pp(req, "", 80))}</PRE>
|
41
|
-
<H2>Response</H2>
|
42
|
-
<PRE>#{WEBrick::HTMLUtils::escape(PP::pp(res, "", 80))}</PRE>
|
43
|
-
</HTML>
|
44
|
-
_end_of_html_
|
45
|
-
res['content-type'] = 'text/html; charset=iso-8859-1'
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def display_query(q)
|
51
|
-
ret = ""
|
52
|
-
q.each{|key, val|
|
53
|
-
ret << "<H3>#{WEBrick::HTMLUtils::escape(key)}</H3>"
|
54
|
-
ret << "<TABLE border=1>"
|
55
|
-
ret << make_tr("val", val.inspect)
|
56
|
-
ret << make_tr("val.to_a", val.to_a.inspect)
|
57
|
-
ret << make_tr("val.to_ary", val.to_ary.inspect)
|
58
|
-
ret << "</TABLE>"
|
59
|
-
}
|
60
|
-
ret
|
61
|
-
end
|
62
|
-
|
63
|
-
def make_tr(arg0, arg1)
|
64
|
-
"<TR><TD>#{arg0}</TD><TD>#{WEBrick::HTMLUtils::escape(arg1)}</TD></TR>"
|
65
|
-
end
|
66
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require "webrick/cgi"
|
3
|
-
require "webrick/https" # should load if it runs on HTTPS server
|
4
|
-
require "./demo-app"
|
5
|
-
|
6
|
-
class DemoCGI < WEBrick::CGI
|
7
|
-
include DemoApplication
|
8
|
-
end
|
9
|
-
|
10
|
-
config = { :NPH => false }
|
11
|
-
cgi = DemoCGI.new(config, "multipart/form-data")
|
12
|
-
cgi.start
|