]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Make UseCanonicalName off correctly grab port info from
authorJim Jagielski <jim@apache.org>
Mon, 17 Nov 2003 17:14:53 +0000 (17:14 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 17 Nov 2003 17:14:53 +0000 (17:14 +0000)
the client. Make UseCanonicalName socket port aware.

PR:
Obtained from:
Submitted by:
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@101803 13f79535-47bb-0310-9956-ffa450edef68

src/CHANGES
src/main/http_core.c

index f1240f5ca2725f018de01c020f90e25acfbe3cae..7620e1089b416cc044a87220d8a1f6c85ef0ffc6 100644 (file)
@@ -1,5 +1,8 @@
 Changes with Apache 1.3.30
 
+  *) UseCanonicalName off was ignoring the client provided
+     port information. [Jim Jagielski]
+
 Changes with Apache 1.3.29
 
   *) SECURITY: CAN-2003-0542 (cve.mitre.org)
index 0896698be84d489d12c23d482a44d567a3f8e3b1..ee496314a1a0b588a0c136055297bd3b415a4cce 100644 (file)
@@ -826,16 +826,27 @@ API_EXPORT(const char *) ap_get_server_name(request_rec *r)
 API_EXPORT(unsigned) ap_get_server_port(const request_rec *r)
 {
     unsigned port;
+    unsigned cport = ntohs(r->connection->local_addr.sin_port);
     core_dir_config *d =
       (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
     
-    port = r->server->port ? r->server->port : ap_default_port(r);
-
     if (d->use_canonical_name == USE_CANONICAL_NAME_OFF
-       || d->use_canonical_name == USE_CANONICAL_NAME_DNS) {
-        return r->hostname ? ntohs(r->connection->local_addr.sin_port)
-                          : port;
+        || d->use_canonical_name == USE_CANONICAL_NAME_DNS) {
+        
+        /* With UseCanonicalName Off Apache will form self-referential
+         * URLs using the hostname and port supplied by the client if
+         * any are supplied (otherwise it will use the canonical name).
+         */
+        port = r->parsed_uri.port_str ? r->parsed_uri.port : 
+          cport ? cport :
+            r->server->port ? r->server->port :
+              ap_default_port(r);
+    } else { /* d->use_canonical_name == USE_CANONICAL_NAME_ON */
+        port = r->server->port ? r->server->port : 
+          cport ? cport :
+            ap_default_port(r);
     }
+
     /* default */
     return port;
 }