diff options
| author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-21 13:17:24 +0000 |
|---|---|---|
| committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-21 13:17:24 +0000 |
| commit | 25cb5862ab7b660176eae186a85a55ad9f088135 (patch) | |
| tree | 6c399a248b922ea4e7be02eb8c6e5d2d9b17a7a3 /lib/webrick/httpserver.rb | |
| parent | cb04cd4423466f5932718077efdcedf1da41495d (diff) | |
| download | ruby-25cb5862ab7b660176eae186a85a55ad9f088135.tar.gz ruby-25cb5862ab7b660176eae186a85a55ad9f088135.tar.xz ruby-25cb5862ab7b660176eae186a85a55ad9f088135.zip | |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@5996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/httpserver.rb')
| -rw-r--r-- | lib/webrick/httpserver.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/webrick/httpserver.rb b/lib/webrick/httpserver.rb index 849706eb4..13574e7de 100644 --- a/lib/webrick/httpserver.rb +++ b/lib/webrick/httpserver.rb @@ -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 |
