webrick 1.4.4 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3c66cf23e2b33e288598d3f59d9e56ca97e465835a68829fb2618938563ad87
4
- data.tar.gz: 99c190d49011abfab1f528cf59a6fb4135c6877c1a49a56b69798143ab9d7849
3
+ metadata.gz: 97da95d5faf45f62560954f75b5fb1536ffdb804a991adbfc1a8da2f312282fb
4
+ data.tar.gz: c4b305ec0e615913868e1707c42656faa197f6f7a26af17505d7b5b38cbaf9dc
5
5
  SHA512:
6
- metadata.gz: acca7540bda5156d247c6e0a94ed686366ce65fb0b83115667653311d28c2e105729f7f729253b2c382c5f9098c324443b3bdf077b89fffb5f0c8b96342c16dd
7
- data.tar.gz: 20a40ff73c5372bc0453a871fe15ffe4f8ec3e53862eccabfb2849b9b5d275bc22ebba48fe4cf7cac3fcfeff30bb5d1619f6f77efcd53f189803f2ec237adf8d
6
+ metadata.gz: 62878410914483e24c84430af518e417f985e2471b8907655d2a096966afdd5f872c29f2d65dc6ee88ab4df216f7077678b5cdf04ba021185f1b40402e565114
7
+ data.tar.gz: ec3e25caa3db02dcf9e7d8dc916cab302c571ba6acb1810681e2051ab7fb35eae06752189a0701c6dee9cd4b5e91f7361c78ceb36e779ed82488702c87d305d9
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -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.
@@ -0,0 +1,63 @@
1
+ # Webrick
2
+
3
+ [![Build Status](https://travis-ci.org/ruby/webrick.svg?branch=master)](https://travis-ci.org/ruby/webrick)
4
+
5
+ WEBrick is an HTTP server toolkit that can be configured as an HTTPS server, a proxy server, and a virtual-host server.
6
+
7
+ WEBrick features complete logging of both server operations and HTTP access.
8
+
9
+ WEBrick supports both basic and digest authentication in addition to algorithms not in RFC 2617.
10
+
11
+ 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.
12
+
13
+ WEBrick also includes tools for daemonizing a process and starting a process at a higher privilege level and dropping permissions.
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'webrick'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install webrick
30
+
31
+ ## Usage
32
+
33
+ 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:
34
+
35
+ ```ruby
36
+ require 'webrick'
37
+
38
+ root = File.expand_path '~/public_html'
39
+ server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => root
40
+ ```
41
+
42
+ To run the server you will need to provide a suitable shutdown hook as
43
+ starting the server blocks the current thread:
44
+
45
+ ```ruby
46
+ trap 'INT' do server.shutdown end
47
+
48
+ server.start
49
+ ```
50
+
51
+ ## Development
52
+
53
+ 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.
54
+
55
+ 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).
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and Patch are welcome on https://bugs.ruby-lang.org/.
60
+
61
+ ## License
62
+
63
+ The gem is available as open source under the terms of the [2-Clause BSD License](https://opensource.org/licenses/BSD-2-Clause).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test" << "test/lib"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/test_*.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -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
- require 'webrick/utils.rb'
215
+ require_relative 'webrick/utils.rb'
216
216
  require 'webrick/accesslog'
217
217
 
218
218
  require 'webrick/htmlutils.rb'
@@ -226,9 +226,9 @@ module WEBrick
226
226
  raise HTTPStatus::BadRequest, "bad URI `#{@unparsed_uri}'."
227
227
  end
228
228
 
229
- if /\Aclose\z/io =~ self["connection"]
229
+ if /close/io =~ self["connection"]
230
230
  @keep_alive = false
231
- elsif /\Akeep-alive\z/io =~ self["connection"]
231
+ elsif /keep-alive/io =~ self["connection"]
232
232
  @keep_alive = true
233
233
  elsif @http_version < "1.1"
234
234
  @keep_alive = false
@@ -503,7 +503,7 @@ module WEBrick
503
503
  return unless socket
504
504
  if tc = self['transfer-encoding']
505
505
  case tc
506
- when /\Achunked\z/io then read_chunked(socket, block)
506
+ when /chunked/io then read_chunked(socket, block)
507
507
  else raise HTTPStatus::NotImplemented, "Transfer-Encoding: #{tc}."
508
508
  end
509
509
  elsif self['content-length'] || @remaining_size
@@ -113,13 +113,14 @@ module WEBrick
113
113
  @chunked = false
114
114
  @filename = nil
115
115
  @sent_size = 0
116
+ @bodytempfile = nil
116
117
  end
117
118
 
118
119
  ##
119
120
  # The response's HTTP status line
120
121
 
121
122
  def status_line
122
- "HTTP/#@http_version #@status #@reason_phrase #{CRLF}"
123
+ "HTTP/#@http_version #@status #@reason_phrase".rstrip << CRLF
123
124
  end
124
125
 
125
126
  ##
@@ -253,7 +254,10 @@ module WEBrick
253
254
  elsif %r{^multipart/byteranges} =~ @header['content-type']
254
255
  @header.delete('content-length')
255
256
  elsif @header['content-length'].nil?
256
- unless @body.is_a?(IO)
257
+ if @body.respond_to? :readpartial
258
+ elsif @body.respond_to? :call
259
+ make_body_tempfile
260
+ else
257
261
  @header['content-length'] = (@body ? @body.bytesize : 0).to_s
258
262
  end
259
263
  end
@@ -282,6 +286,33 @@ module WEBrick
282
286
  end
283
287
  end
284
288
 
289
+ def make_body_tempfile # :nodoc:
290
+ return if @bodytempfile
291
+ bodytempfile = Tempfile.create("webrick")
292
+ if @body.nil?
293
+ # nothing
294
+ elsif @body.respond_to? :readpartial
295
+ IO.copy_stream(@body, bodytempfile)
296
+ @body.close
297
+ elsif @body.respond_to? :call
298
+ @body.call(bodytempfile)
299
+ else
300
+ bodytempfile.write @body
301
+ end
302
+ bodytempfile.rewind
303
+ @body = @bodytempfile = bodytempfile
304
+ @header['content-length'] = bodytempfile.stat.size.to_s
305
+ end
306
+
307
+ def remove_body_tempfile # :nodoc:
308
+ if @bodytempfile
309
+ @bodytempfile.close
310
+ File.unlink @bodytempfile.path
311
+ @bodytempfile = nil
312
+ end
313
+ end
314
+
315
+
285
316
  ##
286
317
  # Sends the headers on +socket+
287
318
 
@@ -318,12 +349,6 @@ module WEBrick
318
349
  end
319
350
  end
320
351
 
321
- def to_s # :nodoc:
322
- ret = ""
323
- send_response(ret)
324
- ret
325
- end
326
-
327
352
  ##
328
353
  # Redirects to +url+ with a WEBrick::HTTPStatus::Redirect +status+.
329
354
  #
@@ -446,6 +471,7 @@ module WEBrick
446
471
  ensure
447
472
  @body.close
448
473
  end
474
+ remove_body_tempfile
449
475
  end
450
476
 
451
477
  def send_body_string(socket)
@@ -478,7 +504,12 @@ module WEBrick
478
504
  socket.write("0#{CRLF}#{CRLF}")
479
505
  else
480
506
  size = @header['content-length'].to_i
481
- @body.call(socket)
507
+ if @bodytempfile
508
+ @bodytempfile.rewind
509
+ IO.copy_stream(@bodytempfile, socket)
510
+ else
511
+ @body.call(socket)
512
+ end
482
513
  @sent_size = size
483
514
  end
484
515
  end
@@ -95,6 +95,7 @@ module WEBrick
95
95
  "tif" => "image/tiff",
96
96
  "tiff" => "image/tiff",
97
97
  "txt" => "text/plain",
98
+ "wasm" => "application/wasm",
98
99
  "xbm" => "image/x-xbitmap",
99
100
  "xhtml" => "text/html",
100
101
  "xls" => "application/vnd.ms-excel",
@@ -14,5 +14,5 @@ module WEBrick
14
14
  ##
15
15
  # The WEBrick version
16
16
 
17
- VERSION = "1.4.4"
17
+ VERSION = "1.5.0"
18
18
  end
@@ -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,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webrick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAKAHASHI Masayoshi
8
8
  - GOTOU YUUZOU
9
9
  - Eric Wong
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-09-29 00:00:00.000000000 Z
13
+ date: 2019-10-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -29,13 +29,19 @@ dependencies:
29
29
  description: WEBrick is an HTTP server toolkit that can be configured as an HTTPS
30
30
  server, a proxy server, and a virtual-host server.
31
31
  email:
32
- -
33
- -
32
+ -
33
+ -
34
34
  - normal@ruby-lang.org
35
35
  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,14 +77,15 @@ files:
71
77
  - lib/webrick/ssl.rb
72
78
  - lib/webrick/utils.rb
73
79
  - lib/webrick/version.rb
80
+ - webrick.gemspec
74
81
  homepage: https://www.ruby-lang.org
75
82
  licenses:
76
83
  - BSD-2-Clause
77
84
  metadata:
78
85
  bug_tracker_uri: https://bugs.ruby-lang.org/projects/ruby-trunk/issues
79
86
  homepage_uri: https://www.ruby-lang.org
80
- source_code_uri: https://svn.ruby-lang.org/repos/ruby
81
- post_install_message:
87
+ source_code_uri: https://git.ruby-lang.org/ruby.git/
88
+ post_install_message:
82
89
  rdoc_options: []
83
90
  require_paths:
84
91
  - lib
@@ -93,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
100
  - !ruby/object:Gem::Version
94
101
  version: '0'
95
102
  requirements: []
96
- rubygems_version: 3.2.0.rc.1
97
- signing_key:
103
+ rubygems_version: 3.0.3
104
+ signing_key:
98
105
  specification_version: 4
99
106
  summary: HTTP server toolkit
100
107
  test_files: []