You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Alexei Kosut <ak...@organic.com> on 1996/06/12 22:54:35 UTC

bugfix for virtualhosts

Recently, there've been some bug reports concering the interaction between
the Listen directives and Host:-header handling and related issues.

I've been able to track down this bug, which stems from the fact that the
Host-header checking code was assuming that all the virtual hosts were on
the same port as the main server, which isn't neccessarily true anymore
(since you can do <VirtualHost host:port>).

Here's a patch. I'd like to see it committed prior to a b4 or final
release of Apache 1.1.0, so if people could look it over, that'd be great.

Thanks!

Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.22
diff -c -r1.22 http_protocol.c
*** http_protocol.c	1996/06/10 02:04:04	1.22
--- http_protocol.c	1996/06/12 20:50:00
***************
*** 352,360 ****
  
  void check_hostalias (request_rec *r) {
    char *host = getword(r->pool, &r->hostname, ':');	/* Get rid of port */
    server_rec *s;
  
!   if (*r->hostname && (atoi(r->hostname) != r->server->port))
      return;
  
    if ((host[strlen(host)-1]) == '.') {
--- 352,361 ----
  
  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;
    server_rec *s;
  
!   if (port && (port != r->server->port))
      return;
  
    if ((host[strlen(host)-1]) == '.') {
***************
*** 365,372 ****
  
    for (s = r->server->next; s; s = s->next) {
      char *names = s->names;
! 
!     if (!strcasecmp(host, s->server_hostname)) {
        r->server = r->connection->server = s;
        if (r->hostlen && !strncmp(r->uri, "http://", 7)) {
  	r->uri += r->hostlen;
--- 366,374 ----
  
    for (s = r->server->next; s; s = s->next) {
      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;


-- Alexei Kosut <ak...@organic.com> 
   http://www.nueva.pvt.k12.ca.us/~akosut/