Received: by taz.hyperreal.com (8.7.6/V2.0) id KAA00718; Sun, 17 Nov 1996 10:41:25 -0800 (PST) Received: from relay-7.mail.demon.net by taz.hyperreal.com (8.7.6/V2.0) with SMTP id KAA00693; Sun, 17 Nov 1996 10:40:59 -0800 (PST) Received: from aaaaaaaa.demon.co.uk ([158.152.178.85]) by relay-5.mail.demon.net id aa510163; 17 Nov 96 14:35 GMT Received: (from andrew@localhost) by aaaaaaaa.demon.co.uk (8.7.6/8.6.9) id OAA01568 for new-httpd@hyperreal.com; Sun, 17 Nov 1996 14:35:28 GMT From: Andrew Wilson Message-Id: <199611171435.OAA01568@aaaaaaaa.demon.co.uk> Subject: Re: Proxy patch to change host -> www.host.com To: Date: Sun, 17 Nov 1996 14:35:28 +0000 (GMT) Cc: new-httpd@hyperreal.com In-Reply-To: from "rasmus@vex.net" at Nov 17, 96 09:21:37 am X-Mailer: ELM [version 2.4 PL24 ME8a] Content-Type: text Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@hyperreal.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: 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