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. */
| 951 | * the ServerName and/or ServerAliases. |
| 952 | */ |
| 953 | AP_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 | /* |
no test coverage detected