Skip to content

Commit 5b6ffe9

Browse files
author
Yieen
committed
improved server_name functionallity
when virtual host is determined only compare ports if both server_name and Host field in request header have a port specified
1 parent ac5822c commit 5b6ffe9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/http/VirtualHost.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ VirtualHost *VirtualHost::matchVirtualHost(Address &address, std::string host) {
7676
(*it)->getContext().getDirective("server_name")[0];
7777
for (std::vector<std::string>::const_iterator itSn = serverNames.begin();
7878
itSn != serverNames.end(); ++itSn) {
79-
if (*itSn == host) return *it;
79+
int diff = std::strcmp(itSn->c_str(), host.c_str());
80+
if (!diff || diff == ':' || -diff == ':') return *it;
8081
}
8182
}
8283
}

0 commit comments

Comments
 (0)