webrick 1.4.4 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of webrick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +61 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/webrick.rb +8 -3
- data/lib/webrick/accesslog.rb +3 -5
- data/lib/webrick/httpauth/authenticator.rb +1 -1
- data/lib/webrick/httpproxy.rb +6 -2
- data/lib/webrick/httprequest.rb +15 -5
- data/lib/webrick/httpresponse.rb +56 -11
- data/lib/webrick/httpservlet/cgihandler.rb +7 -1
- data/lib/webrick/httpservlet/filehandler.rb +15 -4
- data/lib/webrick/httputils.rb +3 -4
- data/lib/webrick/server.rb +3 -0
- data/lib/webrick/ssl.rb +2 -2
- data/lib/webrick/utils.rb +1 -6
- data/lib/webrick/version.rb +1 -1
- data/webrick.gemspec +74 -0
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 800e0427bf3a5f03799b0615f21888ef4827fde35a89663bcf90c055bf4e2221
|
4
|
+
data.tar.gz: ea2b6bdee1ae775c2946e6b16e73a3dbcd18ab27d910cc11eeb72f6eafdc3242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d5511564c5ea1ff1eaf936af515acdaff9b157b767093b13e873a38596470bc42cab4a6be97770856e87d91b069ee05716e73dfea88d165a435737e332fb0f4
|
7
|
+
data.tar.gz: a2eaabfc8c4e16303a59cf45de503aaf71577824a8fb92dc2ad60cc4f5fc2478e707635062ed9abc138e260fbc7bea0cc999f8033e5a0f59deeb0e697ec47c1a
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions
|
5
|
+
are met:
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
16
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
17
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
18
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
19
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
20
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
21
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
22
|
+
SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Webrick
|
2
|
+
|
3
|
+
WEBrick is an HTTP server toolkit that can be configured as an HTTPS server, a proxy server, and a virtual-host server.
|
4
|
+
|
5
|
+
WEBrick features complete logging of both server operations and HTTP access.
|
6
|
+
|
7
|
+
WEBrick supports both basic and digest authentication in addition to algorithms not in RFC 2617.
|
8
|
+
|
9
|
+
A WEBrick server can be composed of multiple WEBrick servers or servlets to provide differing behavior on a per-host or per-path basis. WEBrick includes servlets for handling CGI scripts, ERB pages, Ruby blocks and directory listings.
|
10
|
+
|
11
|
+
WEBrick also includes tools for daemonizing a process and starting a process at a higher privilege level and dropping permissions.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'webrick'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install webrick
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
To create a new WEBrick::HTTPServer that will listen to connections on port 8000 and serve documents from the current user's public_html folder:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'webrick'
|
35
|
+
|
36
|
+
root = File.expand_path '~/public_html'
|
37
|
+
server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => root
|
38
|
+
```
|
39
|
+
|
40
|
+
To run the server you will need to provide a suitable shutdown hook as
|
41
|
+
starting the server blocks the current thread:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
trap 'INT' do server.shutdown end
|
45
|
+
|
46
|
+
server.start
|
47
|
+
```
|
48
|
+
|
49
|
+
## Development
|
50
|
+
|
51
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
52
|
+
|
53
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
Bug reports and Patch are welcome on https://bugs.ruby-lang.org/.
|
58
|
+
|
59
|
+
## License
|
60
|
+
|
61
|
+
The gem is available as open source under the terms of the [2-Clause BSD License](https://opensource.org/licenses/BSD-2-Clause).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "webrick"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/webrick.rb
CHANGED
@@ -15,6 +15,11 @@
|
|
15
15
|
# WEBrick also includes tools for daemonizing a process and starting a process
|
16
16
|
# at a higher privilege level and dropping permissions.
|
17
17
|
#
|
18
|
+
# == Security
|
19
|
+
#
|
20
|
+
# *Warning:* WEBrick is not recommended for production. It only implements
|
21
|
+
# basic security checks.
|
22
|
+
#
|
18
23
|
# == Starting an HTTP server
|
19
24
|
#
|
20
25
|
# To create a new WEBrick::HTTPServer that will listen to connections on port
|
@@ -139,9 +144,9 @@
|
|
139
144
|
# servers. See WEBrick::HTTPAuth, WEBrick::HTTPAuth::BasicAuth and
|
140
145
|
# WEBrick::HTTPAuth::DigestAuth.
|
141
146
|
#
|
142
|
-
# == WEBrick as a
|
147
|
+
# == WEBrick as a daemonized Web Server
|
143
148
|
#
|
144
|
-
# WEBrick can be run as a
|
149
|
+
# WEBrick can be run as a daemonized server for small loads.
|
145
150
|
#
|
146
151
|
# === Daemonizing
|
147
152
|
#
|
@@ -212,7 +217,7 @@ require 'webrick/version.rb'
|
|
212
217
|
require 'webrick/config.rb'
|
213
218
|
require 'webrick/log.rb'
|
214
219
|
require 'webrick/server.rb'
|
215
|
-
|
220
|
+
require_relative 'webrick/utils.rb'
|
216
221
|
require 'webrick/accesslog'
|
217
222
|
|
218
223
|
require 'webrick/htmlutils.rb'
|
data/lib/webrick/accesslog.rb
CHANGED
@@ -149,11 +149,9 @@ module WEBrick
|
|
149
149
|
# Escapes control characters in +data+
|
150
150
|
|
151
151
|
def escape(data)
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
data
|
156
|
-
end
|
152
|
+
data = data.gsub(/[[:cntrl:]\\]+/) {$&.dump[1...-1]}
|
153
|
+
data.untaint if RUBY_VERSION < '2.7'
|
154
|
+
data
|
157
155
|
end
|
158
156
|
end
|
159
157
|
end
|
data/lib/webrick/httpproxy.rb
CHANGED
@@ -115,7 +115,7 @@ module WEBrick
|
|
115
115
|
proxy_auth(req, res)
|
116
116
|
|
117
117
|
begin
|
118
|
-
|
118
|
+
public_send("do_#{req.request_method}", req, res)
|
119
119
|
rescue NoMethodError
|
120
120
|
raise HTTPStatus::MethodNotAllowed,
|
121
121
|
"unsupported method `#{req.request_method}'."
|
@@ -295,6 +295,10 @@ module WEBrick
|
|
295
295
|
return FakeProxyURI
|
296
296
|
end
|
297
297
|
|
298
|
+
def create_net_http(uri, upstream)
|
299
|
+
Net::HTTP.new(uri.host, uri.port, upstream.host, upstream.port)
|
300
|
+
end
|
301
|
+
|
298
302
|
def perform_proxy_request(req, res, req_class, body_stream = nil)
|
299
303
|
uri = req.request_uri
|
300
304
|
path = uri.path.dup
|
@@ -303,7 +307,7 @@ module WEBrick
|
|
303
307
|
upstream = setup_upstream_proxy_authentication(req, res, header)
|
304
308
|
|
305
309
|
body_tmp = []
|
306
|
-
http =
|
310
|
+
http = create_net_http(uri, upstream)
|
307
311
|
req_fib = Fiber.new do
|
308
312
|
http.start do
|
309
313
|
if @config[:ProxyTimeout]
|
data/lib/webrick/httprequest.rb
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
#
|
10
10
|
# $IPR: httprequest.rb,v 1.64 2003/07/13 17:18:22 gotoyuzo Exp $
|
11
11
|
|
12
|
+
require 'fiber'
|
12
13
|
require 'uri'
|
13
14
|
require_relative 'httpversion'
|
14
15
|
require_relative 'httpstatus'
|
@@ -273,13 +274,17 @@ module WEBrick
|
|
273
274
|
self
|
274
275
|
end
|
275
276
|
|
276
|
-
# for IO.copy_stream.
|
277
|
-
# here; but IO.copy_stream does not care.
|
277
|
+
# for IO.copy_stream.
|
278
278
|
def readpartial(size, buf = ''.b) # :nodoc
|
279
279
|
res = @body_tmp.shift or raise EOFError, 'end of file reached'
|
280
|
+
if res.length > size
|
281
|
+
@body_tmp.unshift(res[size..-1])
|
282
|
+
res = res[0..size - 1]
|
283
|
+
end
|
280
284
|
buf.replace(res)
|
281
285
|
res.clear
|
282
|
-
|
286
|
+
# get more chunks - check alive? because we can take a partial chunk
|
287
|
+
@body_rd.resume if @body_rd.alive?
|
283
288
|
buf
|
284
289
|
end
|
285
290
|
|
@@ -517,7 +522,7 @@ module WEBrick
|
|
517
522
|
if @remaining_size > 0 && @socket.eof?
|
518
523
|
raise HTTPStatus::BadRequest, "invalid body size."
|
519
524
|
end
|
520
|
-
elsif BODY_CONTAINABLE_METHODS.member?(@request_method)
|
525
|
+
elsif BODY_CONTAINABLE_METHODS.member?(@request_method) && !@socket.eof
|
521
526
|
raise HTTPStatus::LengthRequired
|
522
527
|
end
|
523
528
|
return @body
|
@@ -611,7 +616,12 @@ module WEBrick
|
|
611
616
|
end
|
612
617
|
if host_port = self["x-forwarded-host"]
|
613
618
|
host_port = host_port.split(",", 2).first
|
614
|
-
|
619
|
+
if host_port =~ /\A(\[[0-9a-fA-F:]+\])(?::(\d+))?\z/
|
620
|
+
@forwarded_host = $1
|
621
|
+
tmp = $2
|
622
|
+
else
|
623
|
+
@forwarded_host, tmp = host_port.split(":", 2)
|
624
|
+
end
|
615
625
|
@forwarded_port = (tmp || (@forwarded_proto == "https" ? 443 : 80)).to_i
|
616
626
|
end
|
617
627
|
if addrs = self["x-forwarded-for"]
|
data/lib/webrick/httpresponse.rb
CHANGED
@@ -51,8 +51,21 @@ module WEBrick
|
|
51
51
|
attr_accessor :reason_phrase
|
52
52
|
|
53
53
|
##
|
54
|
-
# Body may be
|
55
|
-
#
|
54
|
+
# Body may be:
|
55
|
+
# * a String;
|
56
|
+
# * an IO-like object that responds to +#read+ and +#readpartial+;
|
57
|
+
# * a Proc-like object that responds to +#call+.
|
58
|
+
#
|
59
|
+
# In the latter case, either #chunked= should be set to +true+,
|
60
|
+
# or <code>header['content-length']</code> explicitly provided.
|
61
|
+
# Example:
|
62
|
+
#
|
63
|
+
# server.mount_proc '/' do |req, res|
|
64
|
+
# res.chunked = true
|
65
|
+
# # or
|
66
|
+
# # res.header['content-length'] = 10
|
67
|
+
# res.body = proc { |out| out.write(Time.now.to_s) }
|
68
|
+
# end
|
56
69
|
|
57
70
|
attr_accessor :body
|
58
71
|
|
@@ -113,13 +126,14 @@ module WEBrick
|
|
113
126
|
@chunked = false
|
114
127
|
@filename = nil
|
115
128
|
@sent_size = 0
|
129
|
+
@bodytempfile = nil
|
116
130
|
end
|
117
131
|
|
118
132
|
##
|
119
133
|
# The response's HTTP status line
|
120
134
|
|
121
135
|
def status_line
|
122
|
-
"HTTP/#@http_version #@status #@reason_phrase
|
136
|
+
"HTTP/#@http_version #@status #@reason_phrase".rstrip << CRLF
|
123
137
|
end
|
124
138
|
|
125
139
|
##
|
@@ -141,6 +155,7 @@ module WEBrick
|
|
141
155
|
# Sets the response header +field+ to +value+
|
142
156
|
|
143
157
|
def []=(field, value)
|
158
|
+
@chunked = value.to_s.downcase == 'chunked' if field.downcase == 'transfer-encoding'
|
144
159
|
@header[field.downcase] = value.to_s
|
145
160
|
end
|
146
161
|
|
@@ -253,7 +268,10 @@ module WEBrick
|
|
253
268
|
elsif %r{^multipart/byteranges} =~ @header['content-type']
|
254
269
|
@header.delete('content-length')
|
255
270
|
elsif @header['content-length'].nil?
|
256
|
-
|
271
|
+
if @body.respond_to? :readpartial
|
272
|
+
elsif @body.respond_to? :call
|
273
|
+
make_body_tempfile
|
274
|
+
else
|
257
275
|
@header['content-length'] = (@body ? @body.bytesize : 0).to_s
|
258
276
|
end
|
259
277
|
end
|
@@ -282,6 +300,33 @@ module WEBrick
|
|
282
300
|
end
|
283
301
|
end
|
284
302
|
|
303
|
+
def make_body_tempfile # :nodoc:
|
304
|
+
return if @bodytempfile
|
305
|
+
bodytempfile = Tempfile.create("webrick")
|
306
|
+
if @body.nil?
|
307
|
+
# nothing
|
308
|
+
elsif @body.respond_to? :readpartial
|
309
|
+
IO.copy_stream(@body, bodytempfile)
|
310
|
+
@body.close
|
311
|
+
elsif @body.respond_to? :call
|
312
|
+
@body.call(bodytempfile)
|
313
|
+
else
|
314
|
+
bodytempfile.write @body
|
315
|
+
end
|
316
|
+
bodytempfile.rewind
|
317
|
+
@body = @bodytempfile = bodytempfile
|
318
|
+
@header['content-length'] = bodytempfile.stat.size.to_s
|
319
|
+
end
|
320
|
+
|
321
|
+
def remove_body_tempfile # :nodoc:
|
322
|
+
if @bodytempfile
|
323
|
+
@bodytempfile.close
|
324
|
+
File.unlink @bodytempfile.path
|
325
|
+
@bodytempfile = nil
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
|
285
330
|
##
|
286
331
|
# Sends the headers on +socket+
|
287
332
|
|
@@ -318,12 +363,6 @@ module WEBrick
|
|
318
363
|
end
|
319
364
|
end
|
320
365
|
|
321
|
-
def to_s # :nodoc:
|
322
|
-
ret = ""
|
323
|
-
send_response(ret)
|
324
|
-
ret
|
325
|
-
end
|
326
|
-
|
327
366
|
##
|
328
367
|
# Redirects to +url+ with a WEBrick::HTTPStatus::Redirect +status+.
|
329
368
|
#
|
@@ -446,6 +485,7 @@ module WEBrick
|
|
446
485
|
ensure
|
447
486
|
@body.close
|
448
487
|
end
|
488
|
+
remove_body_tempfile
|
449
489
|
end
|
450
490
|
|
451
491
|
def send_body_string(socket)
|
@@ -478,7 +518,12 @@ module WEBrick
|
|
478
518
|
socket.write("0#{CRLF}#{CRLF}")
|
479
519
|
else
|
480
520
|
size = @header['content-length'].to_i
|
481
|
-
@
|
521
|
+
if @bodytempfile
|
522
|
+
@bodytempfile.rewind
|
523
|
+
IO.copy_stream(@bodytempfile, socket)
|
524
|
+
else
|
525
|
+
@body.call(socket)
|
526
|
+
end
|
482
527
|
@sent_size = size
|
483
528
|
end
|
484
529
|
end
|
@@ -28,6 +28,7 @@ module WEBrick
|
|
28
28
|
class CGIHandler < AbstractServlet
|
29
29
|
Ruby = RbConfig.ruby # :nodoc:
|
30
30
|
CGIRunner = "\"#{Ruby}\" \"#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb\"" # :nodoc:
|
31
|
+
CGIRunnerArray = [Ruby, "#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb".freeze].freeze # :nodoc:
|
31
32
|
|
32
33
|
##
|
33
34
|
# Creates a new CGI script servlet for the script at +name+
|
@@ -36,7 +37,12 @@ module WEBrick
|
|
36
37
|
super(server, name)
|
37
38
|
@script_filename = name
|
38
39
|
@tempdir = server[:TempDir]
|
39
|
-
|
40
|
+
interpreter = server[:CGIInterpreter]
|
41
|
+
if interpreter.is_a?(Array)
|
42
|
+
@cgicmd = CGIRunnerArray + interpreter
|
43
|
+
else
|
44
|
+
@cgicmd = "#{CGIRunner} #{interpreter}"
|
45
|
+
end
|
40
46
|
end
|
41
47
|
|
42
48
|
# :stopdoc:
|
@@ -212,9 +212,18 @@ module WEBrick
|
|
212
212
|
|
213
213
|
# :stopdoc:
|
214
214
|
|
215
|
+
def set_filesystem_encoding(str)
|
216
|
+
enc = Encoding.find('filesystem')
|
217
|
+
if enc == Encoding::US_ASCII
|
218
|
+
str.b
|
219
|
+
else
|
220
|
+
str.dup.force_encoding(enc)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
215
224
|
def service(req, res)
|
216
225
|
# if this class is mounted on "/" and /~username is requested.
|
217
|
-
# we're going to override path
|
226
|
+
# we're going to override path information before invoking service.
|
218
227
|
if defined?(Etc) && @options[:UserDir] && req.script_name.empty?
|
219
228
|
if %r|^(/~([^/]+))| =~ req.path_info
|
220
229
|
script_name, user = $1, $2
|
@@ -298,7 +307,7 @@ module WEBrick
|
|
298
307
|
end
|
299
308
|
|
300
309
|
def exec_handler(req, res)
|
301
|
-
raise HTTPStatus::NotFound, "`#{req.path}' not found" unless @root
|
310
|
+
raise HTTPStatus::NotFound, "`#{req.path}' not found." unless @root
|
302
311
|
if set_filename(req, res)
|
303
312
|
handler = get_handler(req, res)
|
304
313
|
call_callback(:HandlerCallback, req, res)
|
@@ -324,11 +333,12 @@ module WEBrick
|
|
324
333
|
end
|
325
334
|
|
326
335
|
def set_filename(req, res)
|
327
|
-
res.filename = @root
|
336
|
+
res.filename = @root
|
328
337
|
path_info = req.path_info.scan(%r|/[^/]*|)
|
329
338
|
|
330
339
|
path_info.unshift("") # dummy for checking @root dir
|
331
340
|
while base = path_info.first
|
341
|
+
base = set_filesystem_encoding(base)
|
332
342
|
break if base == "/"
|
333
343
|
break unless File.directory?(File.expand_path(res.filename + base))
|
334
344
|
shift_path_info(req, res, path_info)
|
@@ -336,6 +346,7 @@ module WEBrick
|
|
336
346
|
end
|
337
347
|
|
338
348
|
if base = path_info.first
|
349
|
+
base = set_filesystem_encoding(base)
|
339
350
|
if base == "/"
|
340
351
|
if file = search_index_file(req, res)
|
341
352
|
shift_path_info(req, res, path_info, file)
|
@@ -364,7 +375,7 @@ module WEBrick
|
|
364
375
|
|
365
376
|
def shift_path_info(req, res, path_info, base=nil)
|
366
377
|
tmp = path_info.shift
|
367
|
-
base = base || tmp
|
378
|
+
base = base || set_filesystem_encoding(tmp)
|
368
379
|
req.path_info = path_info.join
|
369
380
|
req.script_name << base
|
370
381
|
res.filename = File.expand_path(res.filename + base)
|
data/lib/webrick/httputils.rb
CHANGED
@@ -72,6 +72,7 @@ module WEBrick
|
|
72
72
|
"json" => "application/json",
|
73
73
|
"lha" => "application/octet-stream",
|
74
74
|
"lzh" => "application/octet-stream",
|
75
|
+
"mjs" => "application/javascript",
|
75
76
|
"mov" => "video/quicktime",
|
76
77
|
"mpe" => "video/mpeg",
|
77
78
|
"mpeg" => "video/mpeg",
|
@@ -95,6 +96,7 @@ module WEBrick
|
|
95
96
|
"tif" => "image/tiff",
|
96
97
|
"tiff" => "image/tiff",
|
97
98
|
"txt" => "text/plain",
|
99
|
+
"wasm" => "application/wasm",
|
98
100
|
"xbm" => "image/x-xbitmap",
|
99
101
|
"xhtml" => "text/html",
|
100
102
|
"xls" => "application/vnd.ms-excel",
|
@@ -161,10 +163,7 @@ module WEBrick
|
|
161
163
|
end
|
162
164
|
}
|
163
165
|
header.each{|key, values|
|
164
|
-
values.each
|
165
|
-
value.strip!
|
166
|
-
value.gsub!(/\s+/, " ")
|
167
|
-
}
|
166
|
+
values.each(&:strip!)
|
168
167
|
}
|
169
168
|
header
|
170
169
|
end
|
data/lib/webrick/server.rb
CHANGED
@@ -102,6 +102,9 @@ module WEBrick
|
|
102
102
|
@listeners = []
|
103
103
|
@shutdown_pipe = nil
|
104
104
|
unless @config[:DoNotListen]
|
105
|
+
raise ArgumentError, "Port must an integer" unless @config[:Port].to_s == @config[:Port].to_i.to_s
|
106
|
+
|
107
|
+
@config[:Port] = @config[:Port].to_i
|
105
108
|
if @config[:Listen]
|
106
109
|
warn(":Listen option is deprecated; use GenericServer#listen", uplevel: 1)
|
107
110
|
end
|
data/lib/webrick/ssl.rb
CHANGED
@@ -122,7 +122,7 @@ module WEBrick
|
|
122
122
|
ef.issuer_certificate = cert
|
123
123
|
cert.extensions = [
|
124
124
|
ef.create_extension("basicConstraints","CA:FALSE"),
|
125
|
-
ef.create_extension("keyUsage", "keyEncipherment"),
|
125
|
+
ef.create_extension("keyUsage", "keyEncipherment, digitalSignature, keyAgreement, dataEncipherment"),
|
126
126
|
ef.create_extension("subjectKeyIdentifier", "hash"),
|
127
127
|
ef.create_extension("extendedKeyUsage", "serverAuth"),
|
128
128
|
ef.create_extension("nsComment", comment),
|
@@ -130,7 +130,7 @@ module WEBrick
|
|
130
130
|
aki = ef.create_extension("authorityKeyIdentifier",
|
131
131
|
"keyid:always,issuer:always")
|
132
132
|
cert.add_extension(aki)
|
133
|
-
cert.sign(rsa,
|
133
|
+
cert.sign(rsa, "SHA256")
|
134
134
|
|
135
135
|
return [ cert, rsa ]
|
136
136
|
end
|
data/lib/webrick/utils.rb
CHANGED
data/lib/webrick/version.rb
CHANGED
data/webrick.gemspec
ADDED
@@ -0,0 +1,74 @@
|
|
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://github.com/ruby/webrick"
|
65
|
+
s.licenses = ["Ruby", "BSD-2-Clause"]
|
66
|
+
|
67
|
+
if s.respond_to?(:metadata=)
|
68
|
+
s.metadata = {
|
69
|
+
"bug_tracker_uri" => "https://github.com/ruby/webrick/issues",
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
s.add_development_dependency "rake"
|
74
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webrick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAKAHASHI Masayoshi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-12-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -36,6 +36,12 @@ executables: []
|
|
36
36
|
extensions: []
|
37
37
|
extra_rdoc_files: []
|
38
38
|
files:
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- bin/console
|
44
|
+
- bin/setup
|
39
45
|
- lib/webrick.rb
|
40
46
|
- lib/webrick/accesslog.rb
|
41
47
|
- lib/webrick/cgi.rb
|
@@ -71,13 +77,13 @@ files:
|
|
71
77
|
- lib/webrick/ssl.rb
|
72
78
|
- lib/webrick/utils.rb
|
73
79
|
- lib/webrick/version.rb
|
74
|
-
|
80
|
+
- webrick.gemspec
|
81
|
+
homepage: https://github.com/ruby/webrick
|
75
82
|
licenses:
|
83
|
+
- Ruby
|
76
84
|
- BSD-2-Clause
|
77
85
|
metadata:
|
78
|
-
bug_tracker_uri: https://
|
79
|
-
homepage_uri: https://www.ruby-lang.org
|
80
|
-
source_code_uri: https://svn.ruby-lang.org/repos/ruby
|
86
|
+
bug_tracker_uri: https://github.com/ruby/webrick/issues
|
81
87
|
post_install_message:
|
82
88
|
rdoc_options: []
|
83
89
|
require_paths:
|
@@ -93,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
99
|
- !ruby/object:Gem::Version
|
94
100
|
version: '0'
|
95
101
|
requirements: []
|
96
|
-
rubygems_version: 3.2.0
|
102
|
+
rubygems_version: 3.2.0
|
97
103
|
signing_key:
|
98
104
|
specification_version: 4
|
99
105
|
summary: HTTP server toolkit
|