summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2004-07-31 20:01:56 +0000
committerBrad Smith <brad@cvs.openbsd.org>2004-07-31 20:01:56 +0000
commit626472a4a69db330aaf1b6f1c72a6c25143a8294 (patch)
tree1421c3b9b5946693d44343caff8bbbdb4ccfaeb0 /usr.sbin
parentfb64ba50b39b6da1036a1e1e35c1d5f03b58f584 (diff)
Make UseCanonicalName off correctly grab port info from
the client. Make UseCanonicalName socket port aware. ok henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/httpd/src/main/http_core.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/usr.sbin/httpd/src/main/http_core.c b/usr.sbin/httpd/src/main/http_core.c
index 1bf1aba960c..cbf71be830b 100644
--- a/usr.sbin/httpd/src/main/http_core.c
+++ b/usr.sbin/httpd/src/main/http_core.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: http_core.c,v 1.17 2004/06/07 04:24:00 brad Exp $ */
+/* $OpenBSD: http_core.c,v 1.18 2004/07/31 20:01:55 brad Exp $ */
/* ====================================================================
* The Apache Software License, Version 1.1
@@ -857,16 +857,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;
}