webrick 1.7.0 → 1.8.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.

Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/README.md +1 -1
  4. data/Rakefile +10 -3
  5. data/lib/webrick/accesslog.rb +1 -1
  6. data/lib/webrick/cgi.rb +1 -1
  7. data/lib/webrick/compat.rb +1 -1
  8. data/lib/webrick/config.rb +1 -1
  9. data/lib/webrick/cookie.rb +2 -2
  10. data/lib/webrick/htmlutils.rb +1 -1
  11. data/lib/webrick/httpauth/authenticator.rb +1 -1
  12. data/lib/webrick/httpauth/basicauth.rb +1 -1
  13. data/lib/webrick/httpauth/digestauth.rb +1 -1
  14. data/lib/webrick/httpauth/htdigest.rb +1 -1
  15. data/lib/webrick/httpauth/htgroup.rb +1 -1
  16. data/lib/webrick/httpauth/htpasswd.rb +1 -1
  17. data/lib/webrick/httpauth/userdb.rb +1 -1
  18. data/lib/webrick/httpauth.rb +1 -1
  19. data/lib/webrick/httpproxy.rb +1 -1
  20. data/lib/webrick/httprequest.rb +9 -5
  21. data/lib/webrick/httpresponse.rb +36 -12
  22. data/lib/webrick/https.rb +1 -1
  23. data/lib/webrick/httpserver.rb +2 -2
  24. data/lib/webrick/httpservlet/abstract.rb +1 -1
  25. data/lib/webrick/httpservlet/cgi_runner.rb +2 -2
  26. data/lib/webrick/httpservlet/cgihandler.rb +1 -1
  27. data/lib/webrick/httpservlet/erbhandler.rb +1 -1
  28. data/lib/webrick/httpservlet/filehandler.rb +5 -5
  29. data/lib/webrick/httpservlet/prochandler.rb +2 -1
  30. data/lib/webrick/httpservlet.rb +1 -1
  31. data/lib/webrick/httpstatus.rb +1 -1
  32. data/lib/webrick/httputils.rb +15 -4
  33. data/lib/webrick/httpversion.rb +1 -1
  34. data/lib/webrick/log.rb +7 -7
  35. data/lib/webrick/server.rb +2 -2
  36. data/lib/webrick/ssl.rb +17 -13
  37. data/lib/webrick/utils.rb +2 -2
  38. data/lib/webrick/version.rb +2 -2
  39. data/webrick.gemspec +1 -5
  40. metadata +5 -21
  41. data/bin/console +0 -14
  42. data/bin/setup +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 800e0427bf3a5f03799b0615f21888ef4827fde35a89663bcf90c055bf4e2221
4
- data.tar.gz: ea2b6bdee1ae775c2946e6b16e73a3dbcd18ab27d910cc11eeb72f6eafdc3242
3
+ metadata.gz: 32a11a2138bc27a617a7f69e300868cc4957cd208e5358d17aa5d3135c645c1c
4
+ data.tar.gz: 3be4ec01ad7ae153f32db3ab01133c7f7e308e7f6bf984aed5eb08a0646622bb
5
5
  SHA512:
6
- metadata.gz: 5d5511564c5ea1ff1eaf936af515acdaff9b157b767093b13e873a38596470bc42cab4a6be97770856e87d91b069ee05716e73dfea88d165a435737e332fb0f4
7
- data.tar.gz: a2eaabfc8c4e16303a59cf45de503aaf71577824a8fb92dc2ad60cc4f5fc2478e707635062ed9abc138e260fbc7bea0cc999f8033e5a0f59deeb0e697ec47c1a
6
+ metadata.gz: d2eef98cfcc5a16f9da6b99e057ddbe5bb3bb00db407c259fc424092cdcefa94e3cec9dd82f71ab06fe9c423658ec0a4eb33a051f6bf9e3c034da19dc272449f
7
+ data.tar.gz: a0c44a9d8ca6e34666dd783941b908e7c7e496593f93b3f867cec75005b6727c3c7b276ee155e8eb2a886d2b90e47dbdf2ba42f97a1287addd34a76024502896
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem "rake"
6
+ gem "test-unit"
data/README.md CHANGED
@@ -54,7 +54,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
54
54
 
55
55
  ## Contributing
56
56
 
57
- Bug reports and Patch are welcome on https://bugs.ruby-lang.org/.
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/webrick.
58
58
 
59
59
  ## License
60
60
 
data/Rakefile CHANGED
@@ -2,9 +2,16 @@ require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
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']
5
+ t.libs << "test/lib"
6
+ t.ruby_opts << "-rhelper"
7
+ t.test_files = FileList["test/**/test_*.rb"]
8
+ end
9
+
10
+ task :sync_tool do
11
+ require 'fileutils'
12
+ FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
13
+ FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
14
+ FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
8
15
  end
9
16
 
10
17
  task :default => :test
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #--
3
3
  # accesslog.rb -- Access log handling utilities
4
4
  #
data/lib/webrick/cgi.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # cgi.rb -- Yet another CGI library
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # compat.rb -- cross platform compatibility
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # config.rb -- Default configurations.
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # cookie.rb -- Cookie class
4
4
  #
@@ -92,7 +92,7 @@ module WEBrick
92
92
  # The cookie string suitable for use in an HTTP header
93
93
 
94
94
  def to_s
95
- ret = ""
95
+ ret = +""
96
96
  ret << @name << "=" << @value
97
97
  ret << "; " << "Version=" << @version.to_s if @version > 0
98
98
  ret << "; " << "Domain=" << @domain if @domain
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #--
3
3
  # htmlutils.rb -- HTMLUtils Module
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #--
3
3
  # httpauth/authenticator.rb -- Authenticator mix-in module.
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httpauth/basicauth.rb -- HTTP basic access authentication
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httpauth/digestauth.rb -- HTTP digest access authentication
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httpauth/htdigest.rb -- Apache compatible htdigest file
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httpauth/htgroup.rb -- Apache compatible htgroup file
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httpauth/htpasswd -- Apache compatible htpasswd file
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #--
3
3
  # httpauth/userdb.rb -- UserDB mix-in module.
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httpauth.rb -- HTTP access authentication
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httpproxy.rb -- HTTPProxy Class
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httprequest.rb -- HTTPRequest Class
4
4
  #
@@ -171,7 +171,7 @@ module WEBrick
171
171
  @accept_charset = []
172
172
  @accept_encoding = []
173
173
  @accept_language = []
174
- @body = ""
174
+ @body = +""
175
175
 
176
176
  @addr = @peeraddr = nil
177
177
  @attributes = {}
@@ -491,8 +491,7 @@ module WEBrick
491
491
  if @forwarded_host
492
492
  host, port = @forwarded_host, @forwarded_port
493
493
  elsif self["host"]
494
- pattern = /\A(#{URI::REGEXP::PATTERN::HOST})(?::(\d+))?\z/n
495
- host, port = *self['host'].scan(pattern)[0]
494
+ host, port = parse_host_request_line(self["host"])
496
495
  elsif @addr.size > 0
497
496
  host, port = @addr[2], @addr[1]
498
497
  else
@@ -504,6 +503,11 @@ module WEBrick
504
503
  return URI::parse(uri.to_s)
505
504
  end
506
505
 
506
+ def parse_host_request_line(host)
507
+ pattern = /\A(#{URI::REGEXP::PATTERN::HOST})(?::(\d+))?\z/no
508
+ host.scan(pattern)[0]
509
+ end
510
+
507
511
  def read_body(socket, block)
508
512
  return unless socket
509
513
  if tc = self['transfer-encoding']
@@ -522,7 +526,7 @@ module WEBrick
522
526
  if @remaining_size > 0 && @socket.eof?
523
527
  raise HTTPStatus::BadRequest, "invalid body size."
524
528
  end
525
- elsif BODY_CONTAINABLE_METHODS.member?(@request_method) && !@socket.eof
529
+ elsif BODY_CONTAINABLE_METHODS.member?(@request_method)
526
530
  raise HTTPStatus::LengthRequired
527
531
  end
528
532
  return @body
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httpresponse.rb -- HTTPResponse Class
4
4
  #
@@ -105,6 +105,11 @@ module WEBrick
105
105
 
106
106
  attr_reader :sent_size
107
107
 
108
+ ##
109
+ # Set the response body proc as an streaming/upgrade response.
110
+
111
+ attr_accessor :upgrade
112
+
108
113
  ##
109
114
  # Creates a new HTTP response object. WEBrick::Config::HTTP is the
110
115
  # default configuration.
@@ -217,6 +222,16 @@ module WEBrick
217
222
  @keep_alive
218
223
  end
219
224
 
225
+ ##
226
+ # Sets the response to be a streaming/upgrade response.
227
+ # This will disable keep-alive and chunked transfer encoding.
228
+
229
+ def upgrade!(protocol)
230
+ @upgrade = protocol
231
+ @keep_alive = false
232
+ @chunked = false
233
+ end
234
+
220
235
  ##
221
236
  # Sends the response on +socket+
222
237
 
@@ -242,6 +257,14 @@ module WEBrick
242
257
  @header['server'] ||= @config[:ServerSoftware]
243
258
  @header['date'] ||= Time.now.httpdate
244
259
 
260
+ if @upgrade
261
+ @header['connection'] = 'upgrade'
262
+ @header['upgrade'] = @upgrade
263
+ @keep_alive = false
264
+
265
+ return
266
+ end
267
+
245
268
  # HTTP/0.9 features
246
269
  if @request_http_version < "1.0"
247
270
  @http_version = HTTPVersion.new("0.9")
@@ -268,11 +291,10 @@ module WEBrick
268
291
  elsif %r{^multipart/byteranges} =~ @header['content-type']
269
292
  @header.delete('content-length')
270
293
  elsif @header['content-length'].nil?
271
- if @body.respond_to? :readpartial
272
- elsif @body.respond_to? :call
273
- make_body_tempfile
294
+ if @body.respond_to?(:bytesize)
295
+ @header['content-length'] = @body.bytesize.to_s
274
296
  else
275
- @header['content-length'] = (@body ? @body.bytesize : 0).to_s
297
+ @header['connection'] = 'close'
276
298
  end
277
299
  end
278
300
 
@@ -332,7 +354,7 @@ module WEBrick
332
354
 
333
355
  def send_header(socket) # :nodoc:
334
356
  if @http_version.major > 0
335
- data = status_line()
357
+ data = status_line().dup
336
358
  @header.each{|key, value|
337
359
  tmp = key.gsub(/\bwww|^te$|\b\w/){ $&.upcase }
338
360
  data << "#{tmp}: #{check_header(value)}" << CRLF
@@ -419,7 +441,7 @@ module WEBrick
419
441
  # :stopdoc:
420
442
 
421
443
  def error_body(backtrace, ex, host, port)
422
- @body = ''
444
+ @body = +''
423
445
  @body << <<-_end_of_html_
424
446
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
425
447
  <HTML>
@@ -453,11 +475,11 @@ module WEBrick
453
475
  if @request_method == "HEAD"
454
476
  # do nothing
455
477
  elsif chunked?
456
- buf = ''
478
+ buf = +''
457
479
  begin
458
480
  @body.readpartial(@buffer_size, buf)
459
481
  size = buf.bytesize
460
- data = "#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}"
482
+ data = +"#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}"
461
483
  socket.write(data)
462
484
  data.clear
463
485
  @sent_size += size
@@ -517,14 +539,16 @@ module WEBrick
517
539
  @body.call(ChunkedWrapper.new(socket, self))
518
540
  socket.write("0#{CRLF}#{CRLF}")
519
541
  else
520
- size = @header['content-length'].to_i
521
542
  if @bodytempfile
522
543
  @bodytempfile.rewind
523
544
  IO.copy_stream(@bodytempfile, socket)
524
545
  else
525
546
  @body.call(socket)
526
547
  end
527
- @sent_size = size
548
+
549
+ if content_length = @header['content-length']
550
+ @sent_size = content_length.to_i
551
+ end
528
552
  end
529
553
  end
530
554
 
@@ -539,7 +563,7 @@ module WEBrick
539
563
  socket = @socket
540
564
  @resp.instance_eval {
541
565
  size = buf.bytesize
542
- data = "#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}"
566
+ data = +"#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}"
543
567
  socket.write(data)
544
568
  data.clear
545
569
  @sent_size += size
data/lib/webrick/https.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # https.rb -- SSL/TLS enhancement for HTTPServer
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httpserver.rb -- HTTPServer Class
4
4
  #
@@ -285,7 +285,7 @@ module WEBrick
285
285
  end
286
286
 
287
287
  def normalize(dir)
288
- ret = dir ? dir.dup : ""
288
+ ret = dir ? dir.dup : +""
289
289
  ret.sub!(%r|/+\z|, "")
290
290
  ret
291
291
  end
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httpservlet.rb -- HTTPServlet Module
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # cgi_runner.rb -- CGI launcher.
4
4
  #
@@ -10,7 +10,7 @@
10
10
  # $IPR: cgi_runner.rb,v 1.9 2002/09/25 11:33:15 gotoyuzo Exp $
11
11
 
12
12
  def sysread(io, size)
13
- buf = ""
13
+ buf = +""
14
14
  while size > 0
15
15
  tmp = io.sysread(size)
16
16
  buf << tmp
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # cgihandler.rb -- CGIHandler Class
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # erbhandler.rb -- ERBHandler Class
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # filehandler.rb -- FileHandler Module
4
4
  #
@@ -481,9 +481,9 @@ module WEBrick
481
481
  elsif !namewidth or (namewidth = namewidth.to_i) < 2
482
482
  namewidth = 25
483
483
  end
484
- query = query.inject('') {|s, (k, v)| s << '&' << HTMLUtils::escape("#{k}=#{v}")}
484
+ query = query.inject('') {|s, (k, v)| s << '&' << HTMLUtils::escape("#{k}=#{v}")}.dup
485
485
 
486
- type = "text/html"
486
+ type = +"text/html"
487
487
  case enc = Encoding.find('filesystem')
488
488
  when Encoding::US_ASCII, Encoding::ASCII_8BIT
489
489
  else
@@ -492,7 +492,7 @@ module WEBrick
492
492
  res['content-type'] = type
493
493
 
494
494
  title = "Index of #{HTMLUtils::escape(req.path)}"
495
- res.body = <<-_end_of_html_
495
+ res.body = +<<-_end_of_html_
496
496
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
497
497
  <HTML>
498
498
  <HEAD>
@@ -528,7 +528,7 @@ module WEBrick
528
528
  else
529
529
  dname = name
530
530
  end
531
- s = "<TR><TD class=\"name\"><A HREF=\"#{HTTPUtils::escape(name)}#{query if name.end_with?('/')}\">#{HTMLUtils::escape(dname)}</A></TD>"
531
+ s = +"<TR><TD class=\"name\"><A HREF=\"#{HTTPUtils::escape(name)}#{query if name.end_with?('/')}\">#{HTMLUtils::escape(dname)}</A></TD>"
532
532
  s << "<TD class=\"mtime\">" << (time ? time.strftime("%Y/%m/%d %H:%M") : "") << "</TD>"
533
533
  s << "<TD class=\"size\">" << (size >= 0 ? size.to_s : "-") << "</TD></TR>\n"
534
534
  res.body << s
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # prochandler.rb -- ProcHandler Class
4
4
  #
@@ -40,6 +40,7 @@ module WEBrick
40
40
  end
41
41
 
42
42
  alias do_POST do_GET
43
+ alias do_PUT do_GET
43
44
  # :startdoc:
44
45
  end
45
46
 
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httpservlet.rb -- HTTPServlet Utility File
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #--
3
3
  # httpstatus.rb -- HTTPStatus Class
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # httputils.rb -- HTTPUtils Module
4
4
  #
@@ -48,6 +48,7 @@ module WEBrick
48
48
  "ai" => "application/postscript",
49
49
  "asc" => "text/plain",
50
50
  "avi" => "video/x-msvideo",
51
+ "avif" => "image/avif",
51
52
  "bin" => "application/octet-stream",
52
53
  "bmp" => "image/bmp",
53
54
  "class" => "application/octet-stream",
@@ -65,6 +66,7 @@ module WEBrick
65
66
  "gif" => "image/gif",
66
67
  "htm" => "text/html",
67
68
  "html" => "text/html",
69
+ "ico" => "image/x-icon",
68
70
  "jpe" => "image/jpeg",
69
71
  "jpeg" => "image/jpeg",
70
72
  "jpg" => "image/jpeg",
@@ -74,9 +76,11 @@ module WEBrick
74
76
  "lzh" => "application/octet-stream",
75
77
  "mjs" => "application/javascript",
76
78
  "mov" => "video/quicktime",
79
+ "mp4" => "video/mp4",
77
80
  "mpe" => "video/mpeg",
78
81
  "mpeg" => "video/mpeg",
79
82
  "mpg" => "video/mpeg",
83
+ "otf" => "font/otf",
80
84
  "pbm" => "image/x-portable-bitmap",
81
85
  "pdf" => "application/pdf",
82
86
  "pgm" => "image/x-portable-graymap",
@@ -95,8 +99,15 @@ module WEBrick
95
99
  "svg" => "image/svg+xml",
96
100
  "tif" => "image/tiff",
97
101
  "tiff" => "image/tiff",
102
+ "ttc" => "font/collection",
103
+ "ttf" => "font/ttf",
98
104
  "txt" => "text/plain",
99
105
  "wasm" => "application/wasm",
106
+ "webm" => "video/webm",
107
+ "webmanifest" => "application/manifest+json",
108
+ "webp" => "image/webp",
109
+ "woff" => "font/woff",
110
+ "woff2" => "font/woff2",
100
111
  "xbm" => "image/x-xbitmap",
101
112
  "xhtml" => "text/html",
102
113
  "xls" => "application/vnd.ms-excel",
@@ -112,7 +123,7 @@ module WEBrick
112
123
  def load_mime_types(file)
113
124
  # note: +file+ may be a "| command" for now; some people may
114
125
  # rely on this, but currently we do not use this method by default.
115
- open(file){ |io|
126
+ File.open(file){ |io|
116
127
  hash = Hash.new
117
128
  io.each{ |line|
118
129
  next if /^#/ =~ line
@@ -231,7 +242,7 @@ module WEBrick
231
242
  # Quotes and escapes quotes in +str+
232
243
 
233
244
  def quote(str)
234
- '"' << str.gsub(/[\\\"]/o, "\\\1") << '"'
245
+ +'"' << str.gsub(/[\\\"]/o, "\\\1") << '"'
235
246
  end
236
247
  module_function :quote
237
248
 
@@ -495,7 +506,7 @@ module WEBrick
495
506
  # Escapes path +str+
496
507
 
497
508
  def escape_path(str)
498
- result = ""
509
+ result = +""
499
510
  str.scan(%r{/([^/]*)}).each{|i|
500
511
  result << "/" << _escape(i[0], UNESCAPED_PCHAR)
501
512
  }
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #--
3
3
  # HTTPVersion.rb -- presentation of HTTP version
4
4
  #
data/lib/webrick/log.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #--
3
3
  # log.rb -- Log Class
4
4
  #
@@ -86,15 +86,15 @@ module WEBrick
86
86
  end
87
87
 
88
88
  # Shortcut for logging a FATAL message
89
- def fatal(msg) log(FATAL, "FATAL " << format(msg)); end
89
+ def fatal(msg) log(FATAL, "FATAL " + format(msg)); end
90
90
  # Shortcut for logging an ERROR message
91
- def error(msg) log(ERROR, "ERROR " << format(msg)); end
91
+ def error(msg) log(ERROR, "ERROR " + format(msg)); end
92
92
  # Shortcut for logging a WARN message
93
- def warn(msg) log(WARN, "WARN " << format(msg)); end
93
+ def warn(msg) log(WARN, "WARN " + format(msg)); end
94
94
  # Shortcut for logging an INFO message
95
- def info(msg) log(INFO, "INFO " << format(msg)); end
95
+ def info(msg) log(INFO, "INFO " + format(msg)); end
96
96
  # Shortcut for logging a DEBUG message
97
- def debug(msg) log(DEBUG, "DEBUG " << format(msg)); end
97
+ def debug(msg) log(DEBUG, "DEBUG " + format(msg)); end
98
98
 
99
99
  # Will the logger output FATAL messages?
100
100
  def fatal?; @level >= FATAL; end
@@ -118,7 +118,7 @@ module WEBrick
118
118
  # * Otherwise it will return +arg+.inspect.
119
119
  def format(arg)
120
120
  if arg.is_a?(Exception)
121
- "#{arg.class}: #{AccessLog.escape(arg.message)}\n\t" <<
121
+ +"#{arg.class}: #{AccessLog.escape(arg.message)}\n\t" <<
122
122
  arg.backtrace.join("\n\t") << "\n"
123
123
  elsif arg.respond_to?(:to_str)
124
124
  AccessLog.escape(arg.to_str)
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # server.rb -- GenericServer Class
4
4
  #
@@ -102,7 +102,7 @@ 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
105
+ raise ArgumentError, "Port must be an integer" unless @config[:Port].to_s == @config[:Port].to_i.to_s
106
106
 
107
107
  @config[:Port] = @config[:Port].to_i
108
108
  if @config[:Listen]
data/lib/webrick/ssl.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # ssl.rb -- SSL/TLS enhancement for GenericServer
4
4
  #
@@ -95,18 +95,22 @@ module WEBrick
95
95
  # the issuer +cn+ and a +comment+ to be stored in the certificate.
96
96
 
97
97
  def create_self_signed_cert(bits, cn, comment)
98
- rsa = OpenSSL::PKey::RSA.new(bits){|p, n|
99
- case p
100
- when 0; $stderr.putc "." # BN_generate_prime
101
- when 1; $stderr.putc "+" # BN_generate_prime
102
- when 2; $stderr.putc "*" # searching good prime,
103
- # n = #of try,
104
- # but also data from BN_generate_prime
105
- when 3; $stderr.putc "\n" # found good prime, n==0 - p, n==1 - q,
106
- # but also data from BN_generate_prime
107
- else; $stderr.putc "*" # BN_generate_prime
108
- end
109
- }
98
+ rsa = if $VERBOSE
99
+ OpenSSL::PKey::RSA.new(bits){|p, n|
100
+ case p
101
+ when 0; $stderr.putc "." # BN_generate_prime
102
+ when 1; $stderr.putc "+" # BN_generate_prime
103
+ when 2; $stderr.putc "*" # searching good prime,
104
+ # n = #of try,
105
+ # but also data from BN_generate_prime
106
+ when 3; $stderr.putc "\n" # found good prime, n==0 - p, n==1 - q,
107
+ # but also data from BN_generate_prime
108
+ else; $stderr.putc "*" # BN_generate_prime
109
+ end
110
+ }
111
+ else
112
+ OpenSSL::PKey::RSA.new(bits)
113
+ end
110
114
  cert = OpenSSL::X509::Certificate.new
111
115
  cert.version = 2
112
116
  cert.serial = 1
data/lib/webrick/utils.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # utils.rb -- Miscellaneous utilities
4
4
  #
@@ -78,7 +78,7 @@ module WEBrick
78
78
  # Generates a random string of length +len+
79
79
  def random_string(len)
80
80
  rand_max = RAND_CHARS.bytesize
81
- ret = ""
81
+ ret = +""
82
82
  len.times{ ret << RAND_CHARS[rand(rand_max)] }
83
83
  ret
84
84
  end
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #--
3
3
  # version.rb -- version and release date
4
4
  #
@@ -14,5 +14,5 @@ module WEBrick
14
14
  ##
15
15
  # The WEBrick version
16
16
 
17
- VERSION = "1.7.0"
17
+ VERSION = "1.8.0"
18
18
  end
data/webrick.gemspec CHANGED
@@ -18,8 +18,6 @@ Gem::Specification.new do |s|
18
18
  "LICENSE.txt",
19
19
  "README.md",
20
20
  "Rakefile",
21
- "bin/console",
22
- "bin/setup",
23
21
  "lib/webrick.rb",
24
22
  "lib/webrick/accesslog.rb",
25
23
  "lib/webrick/cgi.rb",
@@ -57,7 +55,7 @@ Gem::Specification.new do |s|
57
55
  "lib/webrick/version.rb",
58
56
  "webrick.gemspec",
59
57
  ]
60
- s.required_ruby_version = ">= 2.3.0"
58
+ s.required_ruby_version = ">= 2.4.0"
61
59
 
62
60
  s.authors = ["TAKAHASHI Masayoshi", "GOTOU YUUZOU", "Eric Wong"]
63
61
  s.email = [nil, nil, 'normal@ruby-lang.org']
@@ -69,6 +67,4 @@ Gem::Specification.new do |s|
69
67
  "bug_tracker_uri" => "https://github.com/ruby/webrick/issues",
70
68
  }
71
69
  end
72
-
73
- s.add_development_dependency "rake"
74
70
  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.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAKAHASHI Masayoshi
@@ -10,22 +10,8 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-12-11 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'
13
+ date: 2023-01-27 00:00:00.000000000 Z
14
+ dependencies: []
29
15
  description: WEBrick is an HTTP server toolkit that can be configured as an HTTPS
30
16
  server, a proxy server, and a virtual-host server.
31
17
  email:
@@ -40,8 +26,6 @@ files:
40
26
  - LICENSE.txt
41
27
  - README.md
42
28
  - Rakefile
43
- - bin/console
44
- - bin/setup
45
29
  - lib/webrick.rb
46
30
  - lib/webrick/accesslog.rb
47
31
  - lib/webrick/cgi.rb
@@ -92,14 +76,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
76
  requirements:
93
77
  - - ">="
94
78
  - !ruby/object:Gem::Version
95
- version: 2.3.0
79
+ version: 2.4.0
96
80
  required_rubygems_version: !ruby/object:Gem::Requirement
97
81
  requirements:
98
82
  - - ">="
99
83
  - !ruby/object:Gem::Version
100
84
  version: '0'
101
85
  requirements: []
102
- rubygems_version: 3.2.0
86
+ rubygems_version: 3.5.0.dev
103
87
  signing_key:
104
88
  specification_version: 4
105
89
  summary: HTTP server toolkit
data/bin/console DELETED
@@ -1,14 +0,0 @@
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 DELETED
@@ -1,8 +0,0 @@
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