You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ben Laurie <be...@gonzo.ben.algroup.co.uk> on 1996/07/16 19:35:36 UTC

check_hostalias

I'm deeply suspicious of this code (apart from the large number of spurious
brackets):

void check_hostalias (request_rec *r) {
  char *host = getword(r->pool, &r->hostname, ':');	/* Get rid of port */
  int port = (*r->hostname) ? atoi(r->hostname) : 0;

//// I'm nearly sure the 0 should be the default port instead.

  server_rec *s;

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

  if ((host[strlen(host)-1]) == '.') {
    host[strlen(host)-1] = '\0';
  }

  r->hostname = host;

  for (s = r->server->next; s; s = s->next) {

//// and surely it should be "s=server_conf"? 

    char *names = s->names;
    
    if ((!strcasecmp(host, s->server_hostname)) &&
	(!port || (port == s->port))) {
      r->server = r->connection->server = s;
      if (r->hostlen && !strncmp(r->uri, "http://", 7)) {
	r->uri += r->hostlen;
	parse_uri(r, r->uri);
      }
    }

    if (!names) continue;

    while (*names) {
      char *name = getword_conf (r->pool, &names);

      if ((is_matchexp(name) && !strcasecmp_match(host, name)) ||
	  (!strcasecmp(host, name))) {
	r->server = r->connection->server = s;
	if (r->hostlen && !strncmp(r->uri, "http://", 7)) {
	  r->uri += r->hostlen;
	  r->proxyreq = 0;
	}
      }
    }
  }
}

Thoughts??

Cheers,

Ben.

-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant and    Fax:   +44 (181) 994 6472
Technical Director          Email: ben@algroup.co.uk
A.L. Digital Ltd,           URL: http://www.algroup.co.uk
London, England.