From cd4e5d9455f5dbee3efb8fbfdda73c2677eb2422 Mon Sep 17 00:00:00 2001 From: Martin Kraemer Date: Thu, 8 Nov 2001 12:34:21 +0000 Subject: [PATCH] When no port is given in a "ServerName host" directive, the server_rec->port is now set to zero, not 80. That allows for run-time deduction of the correct server port (depending on SSL/plain, and depending also on the current setting of UseCanonicalName). This change makes redirections work, even with https:// connections. [Martin Kraemer] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91797 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 7 +++++++ server/core.c | 14 +++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 4cb6adbaa5..c40c621198 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,12 @@ Changes with Apache 2.0.28-dev + *) When no port is given in a "ServerName host" directive, the + server_rec->port is now set to zero, not 80. That allows for + run-time deduction of the correct server port (depending on + SSL/plain, and depending also on the current setting of + UseCanonicalName). This change makes redirections + work, even with https:// connections. [Martin Kraemer] + *) Add a '%{note-name}e' argument to mod-headers, which works in the same way as mod_log_confg. [Ian Holsman] diff --git a/server/core.c b/server/core.c index 88251f6ab4..175c0ec1ce 100644 --- a/server/core.c +++ b/server/core.c @@ -756,7 +756,7 @@ AP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r) if (d->use_canonical_name == USE_CANONICAL_NAME_OFF || d->use_canonical_name == USE_CANONICAL_NAME_DNS) { - if (r->hostname) { + if (r->connection && r->connection->client_socket) { apr_sockaddr_t *localsa; apr_socket_addr_get(&localsa, APR_LOCAL, r->connection->client_socket); @@ -1633,15 +1633,15 @@ static const char *server_hostname_port(cmd_parms *cmd, void *dummy, const char portstr - arg); portstr++; port = atoi(portstr); + if (port <= 0 || port >= 65536) { /* 65536 == 1<<16 */ + return apr_pstrcat(cmd->temp_pool, "The port number \"", arg, + "\" is outside the appropriate range " + "(i.e., 1..65535).", NULL); + } } else { cmd->server->server_hostname = apr_pstrdup(cmd->pool, arg); - port = 80; - } - if (port <= 0 || port >= 65536) { /* 65536 == 1<<16 */ - return apr_pstrcat(cmd->temp_pool, "The port number \"", arg, - "\" is outside the appropriate range " - "(i.e., 1..65535).", NULL); + port = 0; } cmd->server->port = port; return NULL; -- 2.50.1