зеркало из https://github.com/github/ruby.git
un.rb: support https
* lib/un.rb: add https support. based on the patch by Flavio Castelli <flavio@castelli.name> in [ruby-core:81901]. [Feature #13714] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6899d6a98c
Коммит
2c59dd61f1
13
lib/un.rb
13
lib/un.rb
|
@ -313,18 +313,29 @@ end
|
|||
# --do-not-reverse-lookup disable reverse lookup
|
||||
# --request-timeout=SECOND request timeout in seconds
|
||||
# --http-version=VERSION HTTP version
|
||||
# --ssl-certificate=CERT The SSL certificate file for the server
|
||||
# --ssl-private-key=KEY The SSL private key file for the server certificate
|
||||
# -v verbose
|
||||
#
|
||||
|
||||
def httpd
|
||||
setup("", "BindAddress=ADDR", "Port=PORT", "MaxClients=NUM", "TempDir=DIR",
|
||||
"DoNotReverseLookup", "RequestTimeout=SECOND", "HTTPVersion=VERSION") do
|
||||
"DoNotReverseLookup", "RequestTimeout=SECOND", "HTTPVersion=VERSION",
|
||||
"SSLCertificate=CERT", "SSLPrivateKey=KEY") do
|
||||
|argv, options|
|
||||
require 'webrick'
|
||||
opt = options[:RequestTimeout] and options[:RequestTimeout] = opt.to_i
|
||||
[:Port, :MaxClients].each do |name|
|
||||
opt = options[name] and (options[name] = Integer(opt)) rescue nil
|
||||
end
|
||||
if cert = options[:SSLCertificate]
|
||||
require 'webrick/https'
|
||||
require 'openssl'
|
||||
options[:SSLCertificate] = OpenSSL::X509::Certificate.new(File.read(cert))
|
||||
options[:SSLEnable] = true
|
||||
options[:SSLPrivateKey] &&= OpenSSL::PKey::RSA.new(File.read(options[:SSLPrivateKey]))
|
||||
options[:Port] ||= 8443 # HTTPS Alternate
|
||||
end
|
||||
options[:Port] ||= 8080 # HTTP Alternate
|
||||
options[:DocumentRoot] = argv.shift || '.'
|
||||
s = WEBrick::HTTPServer.new(options)
|
||||
|
|
Загрузка…
Ссылка в новой задаче