home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / linux / apache / contrib / patches / 1.2 / netscapehost.patch < prev    next >
Encoding:
Internet Message Format  |  1998-06-11  |  1.3 KB

  1. From: "Michiel van Loon" <mfvl@xs4all.nl>
  2. To: <brian@hyperreal.org>
  3. Subject: RE: mod_proxy/1583: Error in netscapehost.patch
  4. Date: Wed, 20 May 1998 18:48:28 +0200
  5.  
  6. Here is the ultra-controversial "host" -> "www.host.com" proxy patch.
  7. This allows the Apache proxy server to behave the same way Netscape
  8. does when given incomplete hostname information; i.e., asked to
  9. look for "ibm" instead of "www.ibm.com".
  10.  
  11.  
  12. --- proxy_http.c.orig    Fri Jan 30 10:14:28 1998
  13. +++ proxy_http.c    Fri Apr 10 21:45:39 1998
  14. @@ -217,7 +217,34 @@
  15.      {
  16.      server.sin_port = htons(destport);
  17.      err = proxy_host2addr(desthost, &server_hp);
  18. -    if (err != NULL) return proxyerror(r, err); /* give up */
  19. +     if (err != NULL) {
  20. +             char try[HUGE_STRING_LEN];
  21. +         int l, changed=0;
  22. +         if(strncmp(desthost,"www.",4))
  23. +         {
  24. +             strcpy(try,"http://www.");
  25. +             strcat(try,desthost);
  26. +             changed=1;
  27. +         } else
  28. +             strcpy(try,desthost);
  29. +         l = strlen(desthost);
  30. +         if(l<=4 || strncmp(&desthost[l-4],".com",4)) {
  31. +             changed=1;
  32. +             strcat(try,".com");
  33. +             strcat(try,urlptr);
  34. +         }
  35. +         if(changed && !strchr(desthost,'.'))
  36. +         {
  37. +             r->status = 302;
  38. +             table_set(r->headers_out, "Location", try);
  39. +             send_http_header(r);
  40. +             return REDIRECT;
  41. +         }
  42. +         return proxyerror(r, err); /* give up */
  43. +     }
  44.      }
  45.  
  46.      sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  47.