1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Display httpd URLs supporting HTTPS

This commit is contained in:
Kentaro Goto 2021-04-27 14:49:37 +09:00 committed by Kentaro Goto
parent 8361675e3a
commit f18e1752dc
Notes: git 2021-08-23 09:59:42 +09:00

View file

@ -347,13 +347,20 @@ def httpd
options[:Port] ||= 8080 # HTTP Alternate
options[:DocumentRoot] = argv.shift || '.'
s = nil
options[:StartCallback] = Proc.new do
options[:StartCallback] = proc {
logger = s.logger
logger.info("To access this server, open this file in a browser:")
s.listeners.each do |listener|
logger.info(" http://#{listener.connect_address.inspect_sockaddr}")
if options[:SSLEnable]
addr = listener.addr
addr[3] = "127.0.0.1" if addr[3] == "0.0.0.0"
addr[3] = "::1" if addr[3] == "::"
logger.info(" https://#{Addrinfo.new(addr).inspect_sockaddr}")
else
logger.info(" http://#{listener.connect_address.inspect_sockaddr}")
end
end
end
}
s = WEBrick::HTTPServer.new(options)
shut = proc {s.shutdown}
siglist = %w"TERM QUIT"