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

* lib/webrick/httpserver.rb (WEBrick::HTTPServer#virtual_host):

sort @virtual_hosts in address, port, host order.

* lib/webrick/httpserver.rb (WEBrick::HTTPServer#lookup_server):
  hostname should not be match if :ServerAlias is not given.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2004-03-21 13:17:24 +00:00
parent 06d1cbb926
commit 48dde6f3e6
2 changed files with 17 additions and 2 deletions

View file

@ -1,3 +1,11 @@
Sun Mar 21 22:17:35 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpserver.rb (WEBrick::HTTPServer#virtual_host):
sort @virtual_hosts in address, port, host order.
* lib/webrick/httpserver.rb (WEBrick::HTTPServer#lookup_server):
hostname should not be match if :ServerAlias is not given.
Sun Mar 21 21:11:16 2004 Keiju Ishitsuka <keiju@ishitsuka.com>
* lib/shell/*: bug fix for Shell#system(command_line_string).

View file

@ -132,14 +132,21 @@ module WEBrick
def virtual_host(server)
@virtual_hosts << server
@virtual_hosts = @virtual_hosts.sort_by{|s|
num = 0
num -= 4 if s[:BindAddress]
num -= 2 if s[:Port]
num -= 1 if s[:ServerName]
num
}
end
def lookup_server(req)
@virtual_hosts.find{|s|
(s[:Port].nil? || req.port == s[:Port]) &&
(s[:BindAddress].nil? || req.addr[3] == s[:BindAddress]) &&
(s[:Port].nil? || req.port == s[:Port]) &&
((s[:ServerName].nil? || req.host == s[:ServerName]) ||
(s[:ServerAlias].nil? || s[:ServerAlias].find{|h| h === req.host}))
(!s[:ServerAlias].nil? && s[:ServerAlias].find{|h| h === req.host}))
}
end