rubysl-webrick 1.0.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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +25 -0
  6. data/README.md +29 -0
  7. data/Rakefile +1 -0
  8. data/lib/rubysl/webrick.rb +2 -0
  9. data/lib/rubysl/webrick/version.rb +5 -0
  10. data/lib/rubysl/webrick/webrick.rb +29 -0
  11. data/lib/webrick.rb +1 -0
  12. data/lib/webrick/accesslog.rb +67 -0
  13. data/lib/webrick/cgi.rb +257 -0
  14. data/lib/webrick/compat.rb +15 -0
  15. data/lib/webrick/config.rb +97 -0
  16. data/lib/webrick/cookie.rb +110 -0
  17. data/lib/webrick/htmlutils.rb +25 -0
  18. data/lib/webrick/httpauth.rb +45 -0
  19. data/lib/webrick/httpauth/authenticator.rb +79 -0
  20. data/lib/webrick/httpauth/basicauth.rb +65 -0
  21. data/lib/webrick/httpauth/digestauth.rb +343 -0
  22. data/lib/webrick/httpauth/htdigest.rb +91 -0
  23. data/lib/webrick/httpauth/htgroup.rb +61 -0
  24. data/lib/webrick/httpauth/htpasswd.rb +83 -0
  25. data/lib/webrick/httpauth/userdb.rb +29 -0
  26. data/lib/webrick/httpproxy.rb +254 -0
  27. data/lib/webrick/httprequest.rb +365 -0
  28. data/lib/webrick/httpresponse.rb +327 -0
  29. data/lib/webrick/https.rb +63 -0
  30. data/lib/webrick/httpserver.rb +210 -0
  31. data/lib/webrick/httpservlet.rb +22 -0
  32. data/lib/webrick/httpservlet/abstract.rb +71 -0
  33. data/lib/webrick/httpservlet/cgi_runner.rb +45 -0
  34. data/lib/webrick/httpservlet/cgihandler.rb +104 -0
  35. data/lib/webrick/httpservlet/erbhandler.rb +54 -0
  36. data/lib/webrick/httpservlet/filehandler.rb +398 -0
  37. data/lib/webrick/httpservlet/prochandler.rb +33 -0
  38. data/lib/webrick/httpstatus.rb +126 -0
  39. data/lib/webrick/httputils.rb +391 -0
  40. data/lib/webrick/httpversion.rb +49 -0
  41. data/lib/webrick/log.rb +88 -0
  42. data/lib/webrick/server.rb +200 -0
  43. data/lib/webrick/ssl.rb +126 -0
  44. data/lib/webrick/utils.rb +100 -0
  45. data/lib/webrick/version.rb +13 -0
  46. data/rubysl-webrick.gemspec +23 -0
  47. metadata +145 -0
@@ -0,0 +1,100 @@
1
+ #
2
+ # utils.rb -- Miscellaneous utilities
3
+ #
4
+ # Author: IPR -- Internet Programming with Ruby -- writers
5
+ # Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
6
+ # Copyright (c) 2002 Internet Programming with Ruby writers. All rights
7
+ # reserved.
8
+ #
9
+ # $IPR: utils.rb,v 1.10 2003/02/16 22:22:54 gotoyuzo Exp $
10
+
11
+ require 'socket'
12
+ require 'fcntl'
13
+ begin
14
+ require 'etc'
15
+ rescue LoadError
16
+ nil
17
+ end
18
+
19
+ module WEBrick
20
+ module Utils
21
+ def set_non_blocking(io)
22
+ flag = File::NONBLOCK
23
+ if defined?(Fcntl::F_GETFL)
24
+ flag |= io.fcntl(Fcntl::F_GETFL)
25
+ end
26
+ io.fcntl(Fcntl::F_SETFL, flag)
27
+ end
28
+ module_function :set_non_blocking
29
+
30
+ def set_close_on_exec(io)
31
+ if defined?(Fcntl::FD_CLOEXEC)
32
+ io.fcntl(Fcntl::FD_CLOEXEC, 1)
33
+ end
34
+ end
35
+ module_function :set_close_on_exec
36
+
37
+ def su(user)
38
+ if defined?(Etc)
39
+ pw = Etc.getpwnam(user)
40
+ Process::initgroups(user, pw.gid)
41
+ Process::Sys::setgid(pw.gid)
42
+ Process::Sys::setuid(pw.uid)
43
+ else
44
+ warn("WEBrick::Utils::su doesn't work on this platform")
45
+ end
46
+ end
47
+ module_function :su
48
+
49
+ def getservername
50
+ host = Socket::gethostname
51
+ begin
52
+ Socket::gethostbyname(host)[0]
53
+ rescue
54
+ host
55
+ end
56
+ end
57
+ module_function :getservername
58
+
59
+ def create_listeners(address, port, logger=nil)
60
+ unless port
61
+ raise ArgumentError, "must specify port"
62
+ end
63
+ res = Socket::getaddrinfo(address, port,
64
+ Socket::AF_UNSPEC, # address family
65
+ Socket::SOCK_STREAM, # socket type
66
+ 0, # protocol
67
+ Socket::AI_PASSIVE) # flag
68
+ last_error = nil
69
+ sockets = []
70
+ res.each{|ai|
71
+ begin
72
+ logger.debug("TCPServer.new(#{ai[3]}, #{port})") if logger
73
+ sock = TCPServer.new(ai[3], port)
74
+ port = sock.addr[1] if port == 0
75
+ Utils::set_close_on_exec(sock)
76
+ sockets << sock
77
+ rescue => ex
78
+ logger.warn("TCPServer Error: #{ex}") if logger
79
+ last_error = ex
80
+ end
81
+ }
82
+ raise last_error if sockets.empty?
83
+ return sockets
84
+ end
85
+ module_function :create_listeners
86
+
87
+ RAND_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
88
+ "0123456789" +
89
+ "abcdefghijklmnopqrstuvwxyz"
90
+
91
+ def random_string(len)
92
+ rand_max = RAND_CHARS.size
93
+ ret = ""
94
+ len.times{ ret << RAND_CHARS[rand(rand_max)] }
95
+ ret
96
+ end
97
+ module_function :random_string
98
+
99
+ end
100
+ end
@@ -0,0 +1,13 @@
1
+ #
2
+ # version.rb -- version and release date
3
+ #
4
+ # Author: IPR -- Internet Programming with Ruby -- writers
5
+ # Copyright (c) 2000 TAKAHASHI Masayoshi, GOTOU YUUZOU
6
+ # Copyright (c) 2003 Internet Programming with Ruby writers. All rights
7
+ # reserved.
8
+ #
9
+ # $IPR: version.rb,v 1.74 2003/07/22 19:20:43 gotoyuzo Exp $
10
+
11
+ module WEBrick
12
+ VERSION = "1.3.1"
13
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ require './lib/rubysl/webrick/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "rubysl-webrick"
6
+ spec.version = RubySL::WEBrick::VERSION
7
+ spec.authors = ["Brian Shirai"]
8
+ spec.email = ["brixen@gmail.com"]
9
+ spec.description = %q{Ruby standard library webrick.}
10
+ spec.summary = %q{Ruby standard library webrick.}
11
+ spec.homepage = "https://github.com/rubysl/rubysl-webrick"
12
+ spec.license = "BSD"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "mspec", "~> 1.5"
22
+ spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
23
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubysl-webrick
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Shirai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubysl-prettyprint
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ description: Ruby standard library webrick.
70
+ email:
71
+ - brixen@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .travis.yml
78
+ - Gemfile
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - lib/rubysl/webrick.rb
83
+ - lib/rubysl/webrick/version.rb
84
+ - lib/rubysl/webrick/webrick.rb
85
+ - lib/webrick.rb
86
+ - lib/webrick/accesslog.rb
87
+ - lib/webrick/cgi.rb
88
+ - lib/webrick/compat.rb
89
+ - lib/webrick/config.rb
90
+ - lib/webrick/cookie.rb
91
+ - lib/webrick/htmlutils.rb
92
+ - lib/webrick/httpauth.rb
93
+ - lib/webrick/httpauth/authenticator.rb
94
+ - lib/webrick/httpauth/basicauth.rb
95
+ - lib/webrick/httpauth/digestauth.rb
96
+ - lib/webrick/httpauth/htdigest.rb
97
+ - lib/webrick/httpauth/htgroup.rb
98
+ - lib/webrick/httpauth/htpasswd.rb
99
+ - lib/webrick/httpauth/userdb.rb
100
+ - lib/webrick/httpproxy.rb
101
+ - lib/webrick/httprequest.rb
102
+ - lib/webrick/httpresponse.rb
103
+ - lib/webrick/https.rb
104
+ - lib/webrick/httpserver.rb
105
+ - lib/webrick/httpservlet.rb
106
+ - lib/webrick/httpservlet/abstract.rb
107
+ - lib/webrick/httpservlet/cgi_runner.rb
108
+ - lib/webrick/httpservlet/cgihandler.rb
109
+ - lib/webrick/httpservlet/erbhandler.rb
110
+ - lib/webrick/httpservlet/filehandler.rb
111
+ - lib/webrick/httpservlet/prochandler.rb
112
+ - lib/webrick/httpstatus.rb
113
+ - lib/webrick/httputils.rb
114
+ - lib/webrick/httpversion.rb
115
+ - lib/webrick/log.rb
116
+ - lib/webrick/server.rb
117
+ - lib/webrick/ssl.rb
118
+ - lib/webrick/utils.rb
119
+ - lib/webrick/version.rb
120
+ - rubysl-webrick.gemspec
121
+ homepage: https://github.com/rubysl/rubysl-webrick
122
+ licenses:
123
+ - BSD
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.0.7
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Ruby standard library webrick.
145
+ test_files: []