Index: src/main/http_protocol.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/main/http_protocol.c,v retrieving revision 1.188 retrieving revision 1.190 diff -u -r1.188 -r1.190 --- http_protocol.c 1998/02/09 01:09:40 1.188 +++ http_protocol.c 1998/02/21 01:18:28 1.190 @@ -625,9 +625,10 @@ const char *check_fulluri(request_rec *r, const char *uri) { - char *name, *host, *proto; - int i, plen; + char *host, *proto, *slash, *colon; + int plen; unsigned port; + const char *res_uri; /* This routine parses full URLs, if they match the server */ proto = http_method(r); @@ -635,33 +636,49 @@ if (strncasecmp(uri, proto, plen) || strncasecmp(uri + plen, "://", 3)) return uri; - name = pstrdup(r->pool, uri + plen); + host = pstrdup(r->pool, uri + plen + 3); /* Find the hostname, assuming a valid request */ - i = ind(name, '/'); - name[i] = '\0'; + slash = strchr(host, '/'); + if (slash) { + *slash = 0; + } + else { + slash = host + strlen(host); + } /* Find the port */ - host = getword_nc(r->pool, &name, ':'); - if (*name) - port = atoi(name); - else + colon = strchr(host, ':'); + if (colon) { + *colon = '\0'; + port = atoi(colon+1); + if (port == 0) { + return uri; + } + } + else { port = default_port(r); + } /* Make sure ports patch */ if (port != r->server->port) return uri; /* Save it for later use */ - r->hostname = pstrdup(r->pool, host); - r->hostlen = plen + 3 + i; + r->hostname = host; + r->hostlen = plen + 3 + slash - host; + res_uri = uri + r->hostlen; + /* deal with "http://host" */ + if (*res_uri == '\0') { + res_uri = "/"; + } /* The easy cases first */ if (!strcasecmp(host, r->server->server_hostname)) { - return (uri + r->hostlen); + return res_uri; } else if (!strcmp(host, inet_ntoa(r->connection->local_addr.sin_addr))) { - return (uri + r->hostlen); + return res_uri; } else { /* Now things get a bit trickier - check the IP address(es) of @@ -674,7 +691,7 @@ for (n = 0; hp->h_addr_list[n] != NULL; n++) { if (r->connection->local_addr.sin_addr.s_addr == (((struct in_addr *) (hp->h_addr_list[n]))->s_addr)) { - return (uri + r->hostlen); + return res_uri; } } }