akosut      96/03/25 22:53:56

  Modified:    src       http_protocol.c
  Log:
  Add routine to internally parse full-URI requests that are directed to the
  server (e.g. "GET http://www.apache.org/ HTTP/1.0"), regardless of whether
  or not a proxy module is installed. If the server and port do not match where
  the server is currently listening, the request is passed on untouched.
  
  Revision  Changes    Path
  1.9       +52 -1     apache/src/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_protocol.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -C3 -r1.8 -r1.9
  *** http_protocol.c   1996/03/21 03:50:15     1.8
  --- http_protocol.c   1996/03/26 06:53:54     1.9
  ***************
  *** 254,259 ****
  --- 254,309 ----
        }
    }
    
  + char *check_fulluri (request_rec *r, char *uri) {
  +   char *name, *host;
  +   int i, port;
  + 
  +   /* This routine parses full URLs, if they match the server */
  +   if (strncmp(uri, "http://";, 7)) return uri;
  +   name = pstrcat(r->pool, uri + 7);
  +   
  +   /* Find the hostname, assuming a valid request */
  +   i = ind(name, '/');
  +   name[i] = '\0';
  + 
  +   /* Find the port */
  +   host = getword(r->pool, &name, ':');
  +   if (*name) port = atoi(name);
  +   else {
  +     host = name;
  +     port = 80;
  +   }
  + 
  +   /* Make sure ports patch */
  +   if (port != r->server->port) return uri;
  + 
  +   /* The easy cases first */
  +   if (!strcasecmp(host, r->server->server_hostname)) {
  +     return (uri + 7 + i);
  +   }
  +   else if (!strcmp(host, inet_ntoa(r->connection->local_addr.sin_addr))) {
  +     return (uri + 7 + i);
  +   }
  + 
  +   /* Now things get a bit trickier - check the IP address(es) of the host */
  +   /* they gave, see if it matches ours.                                   */
  +   else {
  +     struct hostent *hp;
  +     int n;
  + 
  +     if ((hp = gethostbyname(host))) {
  +       for (n = 0; hp->h_addr_list[n] != NULL; n++) {
  +     if (r->connection->local_addr.sin_addr.s_addr ==
  +         (((struct in_addr *)(hp->h_addr_list[n]))->s_addr)) {
  +       return (uri + 7 + i);
  +     }
  +       }
  +     }
  +   }
  +   
  +   return uri;
  + }
  + 
    int read_request_line (request_rec *r)
    {
        char l[HUGE_STRING_LEN];
  ***************
  *** 269,274 ****
  --- 319,325 ----
        r->the_request = pstrdup (r->pool, l);
        r->method = getword(r->pool, &ll,' ');
        uri = getword(r->pool, &ll,' ');
  +     uri = check_fulluri(r, uri);
        parse_uri (r, uri);
        
        r->assbackwards = (ll[0] == '\0');
  ***************
  *** 482,488 ****
       "Bad Gateway"
    };
    
  ! int index_of_response(int err_no) { 
       char *cptr, err_string[10];
       static char *response_codes = RESPONSE_CODE_LIST;
       int index_number;
  --- 533,539 ----
       "Bad Gateway"
    };
    
  ! int index_of_response(int err_no) {
       char *cptr, err_string[10];
       static char *response_codes = RESPONSE_CODE_LIST;
       int index_number;
  
  
  

Reply via email to