MCPcopy Create free account
hub / github.com/apache/httpd / ap_matches_request_vhost

Function ap_matches_request_vhost

server/vhost.c:953–991  ·  view source on GitHub ↗

Suppose a request came in on the same socket as this r, and included * a header "Host: host:port", would it map to r->server? It's more * than just that though. When we do the normal matches for each request * we don't even bother considering Host: etc on non-namevirtualhosts, * we just call it a match. But here we require the host:port to match * the ServerName and/or ServerAliases. */

Source from the content-addressed store, hash-verified

951 * the ServerName and/or ServerAliases.
952 */
953AP_DECLARE(int) ap_matches_request_vhost(request_rec *r, const char *host,
954 apr_port_t port)
955{
956 server_rec *s;
957 server_addr_rec *sar;
958
959 s = r->server;
960
961 /* search all the <VirtualHost> values */
962 /* XXX: If this is a NameVirtualHost then we may not be doing the Right Thing
963 * consider:
964 *
965 * NameVirtualHost 10.1.1.1
966 * <VirtualHost 10.1.1.1>
967 * ServerName v1
968 * </VirtualHost>
969 * <VirtualHost 10.1.1.1>
970 * ServerName v2
971 * </VirtualHost>
972 *
973 * Suppose r->server is v2, and we're asked to match "10.1.1.1". We'll say
974 * "yup it's v2", when really it isn't... if a request came in for 10.1.1.1
975 * it would really go to v1.
976 */
977 for (sar = s->addrs; sar; sar = sar->next) {
978 if ((sar->host_port == 0 || port == sar->host_port)
979 && !strcasecmp(host, sar->virthost)) {
980 return 1;
981 }
982 }
983
984 /* the Port has to match now, because the rest don't have ports associated
985 * with them. */
986 if (port != s->port) {
987 return 0;
988 }
989
990 return matches_aliases(s, host);
991}
992
993
994/*

Callers 5

dav_lookup_uriFunction · 0.85
get_public_https_serverFunction · 0.85
link_md_to_serversFunction · 0.85
proxy_detectFunction · 0.85
reduce_uriFunction · 0.85

Calls 1

matches_aliasesFunction · 0.85

Tested by

no test coverage detected