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...@vex.net on 1996/11/17 15:21:37 UTC

Proxy patch to change host -> www.host.com

Today, being the patch deadline, I was hoping to sneak this one in.

I have gotten very used to a little shortcut built into Netscape's
host->IP resolver.  If you feed it a single word hostname, ie. "ibm",
it will then turn it into "www.ibm.com" for you if "ibm" in itself 
doesn't resolve.  The Apache proxy doesn't currently handle this.
Here is a simple patch to make it do so:

*** proxy_util.old	Sun Nov 17 09:49:33 1996
--- proxy_util.c	Sun Nov 17 10:19:51 1996
***************
*** 690,694 ****
  
  	hp = gethostbyname(host);
! 	if (hp == NULL) return "Host not found";
  	memcpy(addr, hp->h_addr, sizeof(struct in_addr));
      } else
--- 690,714 ----
  
  	hp = gethostbyname(host);
! 	if (hp == NULL)
! 	{
! 		char try[HUGE_STRING_LEN];
! 		char *p;
! 		int l;
! 
! 		if(strncmp(host,"www.",4)) 
! 		{
! 			strcpy(try,"www.");
! 			strcat(try,host);
! 		} else
! 			strcpy(try,host);
! 
! 		l = strlen(host);
! 		if(l<=4 || strncmp(&host[l-4],".com",4))
! 			strcat(try,".com");
! 
! 		hp = gethostbyname(try);
! 		if (hp == NULL)
! 			return "Host not found";
! 	}
  	memcpy(addr, hp->h_addr, sizeof(struct in_addr));
      } else


Re: Proxy patch to change host -> www.host.com

Posted by Alexei Kosut <ak...@nueva.pvt.k12.ca.us>.
On Sun, 17 Nov 1996 rasmus@vex.net wrote:

> I have gotten very used to a little shortcut built into Netscape's
> host->IP resolver.  If you feed it a single word hostname, ie. "ibm",
> it will then turn it into "www.ibm.com" for you if "ibm" in itself 
> doesn't resolve.  The Apache proxy doesn't currently handle this.
> Here is a simple patch to make it do so:

Very dangerous, doing it this way. Note that Netscape, if it's doing
this, changes the status bar, so you know it's been done. This patch
would make it happen without the knowledge of user. They would still
see "http://ibm/" in their status bar. I would perfer that if the
Apache proxy did this (and I'm not sure it should - but I'm not sure
it shouldn't), it should check to see if the www.*.com address exists,
and if it does, it should send a redirect to the client.

-- 
________________________________________________________________________
Alexei Kosut <ak...@nueva.pvt.k12.ca.us>      The Apache HTTP Server
URL: http://www.nueva..pvt.k12.ca.us/~akosut/   http://www.apache.org/