httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Wilson <and...@aaaaaaaa.demon.co.uk>
Subject Re: Proxy patch to change host -> www.host.com
Date Sun, 17 Nov 1996 14:35:28 GMT
> 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:

Whaaaat!?  Are you serious about this ;)

> *** 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

Mime
View raw message