On Thu, 2002-08-29 at 04:28, Bill Barker wrote:

> The question in 12052 is whether Apache should use the socket port (as it
> does now), or the port in the Host header.  When this came up with the
> Coyote/Http11 connector, the decision was that the Host header was the
> correct one.  I'd have to say that the bug is valid.

This is what the API (2.2) docs say about the getServerPort():

----------------
Returns the port number on which this request was received. For HTTP
servlets, same as the value of the CGI variable SERVER_PORT.
----------------

This in itself could be contradicting, but I think that in the case of
Apache it is pretty straightforward.

This is what Apache 2.0 does to populate the variable SERVER_PORT:

----------------
apr_table_addn(e, "SERVER_PORT",
                  apr_psprintf(r->pool, "%u", ap_get_server_port(r)));
----------------

And this is the ap_get_server_port():

----------------
AP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r)
{
    apr_port_t port;
    core_dir_config *d =
      (core_dir_config *)ap_get_module_config(r->per_dir_config,
&core_module);

    if (d->use_canonical_name == USE_CANONICAL_NAME_OFF
        || 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 ? r->parsed_uri.port :
               r->server->port ? r->server->port :
               ap_default_port(r);
    }
    else { /* d->use_canonical_name == USE_CANONICAL_NAME_ON */

        /* With UseCanonicalName on (and in all versions prior to 1.3)
         * Apache will use the hostname and port specified in the
         * ServerName directive to construct a canonical name for the
         * server. (If no port was specified in the ServerName
         * directive, Apache uses the port supplied by the client if
         * any is supplied, and finally the default port for the
protocol
         * used.
         */
        port = r->server->port ? r->server->port :
               r->connection->local_addr->port ?
r->connection->local_addr->port
               ap_default_port(r);
    }

    /* default */
    return port;
}
----------------

This doesn't seem like coming from headers, but rather from URL or as
indicated by the server itself. What do you think?

Bojan


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to