You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by ra...@mail1.bellglobal.com on 1997/01/13 17:23:43 UTC

netscapehost.patch updated

Could someone please replace the netscapehost.patch file in the 1.2 contrib
directory with the following?  (Brian, any chance I could get a Hyperreal
account to avoid bugging the list with typo fixes?)

===[CUT]===

Here is the ultra-controversial "host" -> "www.host.com" proxy patch.
This allows the Apache proxy server to behave the same way Netscape
does when given incomplete hostname information; i.e., asked to
look for "ibm" instead of "www.ibm.com".

Please download this patch by holding down your shift buttong and clicking
on the link.  If you just copy and paste it from your browser window, you 
will lose whitespace formatting.  You can do this, but then you have to
remember to add the "-l" flag when you run patch.  The -l argument to patch
will tell it to ignore whitespace differences.

In order to install this patch, copy this file to your Apache 
src/modules/proxy directory and type: patch -p1 -l <filename
Then recompile Apache.


*** proxy_http.c.orig	Mon Dec  9 23:16:44 1996
--- proxy_http.c	Fri Jan 10 13:31:15 1997
***************
*** 203,209 ****
      {
  	server.sin_port = htons(destport);
  	err = proxy_host2addr(desthost, &server.sin_addr);
! 	if (err != NULL) return proxyerror(r, err); /* give up */
      }
  
      sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
--- 203,236 ----
      {
  	server.sin_port = htons(destport);
  	err = proxy_host2addr(desthost, &server.sin_addr);
! 	if (err != NULL) {
! 	        char try[HUGE_STRING_LEN];
! 		int l, changed=0;
! 
! 		if(strncmp(desthost,"www.",4))
! 		{
! 			strcpy(try,"http://www.");
! 			strcat(try,desthost);
! 			changed=1;
! 		} else
! 			strcpy(try,desthost);
! 
! 		l = strlen(desthost);
! 		if(l<=4 || strncmp(&desthost[l-4],".com",4)) {
! 			changed=1;
! 			strcat(try,".com");
! 			strcat(try,url);
! 		}
! 
! 		if(changed && !strchr(desthost,'.'))
! 		{
! 			r->status = 302;
! 			table_set(r->headers_out, "Location", try);
! 			send_http_header(r);
! 			return REDIRECT;
! 		}
! 		return proxyerror(r, err); /* give up */
! 	}
      }
  
      sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);