httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Kraemer <Martin.Krae...@mch.sni.de>
Subject Re: [PATCH] PR#1049: name-based, multi-port servers don't work
Date Tue, 16 Sep 1997 10:26:12 GMT
On Fri, Sep 12, 1997 at 09:06:40PM -0700, Dean Gaudet wrote:
> In 1.3 with this port test, name-based vhosts can only work if they are on
> the same port as the main server, requests on other ports always go to
> the main server (or a _default_).

+1 on the patch, but:
It's even worse than that. The implicit assumption "if no port is given
then use port 80" in check_hostalias() is wrong because in
check_fulluri(), the lines
    /* Find the port */
    host = getword_nc(r->pool, &name, ':');
    ...
    r->hostname = pstrdup(r->pool, host);
strip off the port part already before assigning it to r->hostname.
Because check_fulluri() is the first thing that's called after the
request line has been read, the r->hostname therefore doesn't have a
port any more, and the assumption to use 80 is wrong.

Shouldn't check_hostalias() therefore read (pseudo-patch):

static void check_hostalias(request_rec *r)
{
    const char *hostname = r->hostname;
    char *host = getword(r->pool, &hostname, ':');      /* Get rid of port */
-   unsigned port = (*hostname) ? atoi(hostname) : 80;
+   unsigned port = (*hostname) ? atoi(hostname) : r->server->port;
    server_rec *s;
    int l;
    server_rec_chain *src;

-   if (port && (port != r->server->port))
-       return;

(BTW: I have added an experimental uri-parsing addition to parse_uri()
which chops the absoluteURI into all of its components and stores them
in the request structure for later use by http_protocol and other
modules. With such an information, it becomes much easier to get the
information we want:

static void check_hostalias(request_rec *r)
{
    char *host = r->parsed_uri.hostname;
    unsigned port = r->parsed_uri.has_port ? r->parsed_uri.port : DEFAULT_PORT;
    server_rec *s;

I haven't tested it thoroughly enough yet to offer it as a patch.
I hope I'll find the time to do so soon.)

    Martin
-- 
| S I E M E N S |  <Martin.Kraemer@mch.sni.de>  |      Siemens Nixdorf
| ------------- |   Voice: +49-89-636-46021     |  Informationssysteme AG
| N I X D O R F |   FAX:   +49-89-636-44994     |   81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request

Mime
View raw message