From owner-freebsd-bugs Thu Dec 27 3:10:13 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 0802737B419 for ; Thu, 27 Dec 2001 03:10:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id fBRBA2B88199; Thu, 27 Dec 2001 03:10:02 -0800 (PST) (envelope-from gnats) Received: from raven.robbins.dropbear.id.au (060.c.001.mel.iprimus.net.au [203.134.131.60]) by hub.freebsd.org (Postfix) with ESMTP id 5B27C37B417 for ; Thu, 27 Dec 2001 03:06:47 -0800 (PST) Received: (from tim@localhost) by raven.robbins.dropbear.id.au (8.11.6/8.11.6) id fBRB6Vh43939; Thu, 27 Dec 2001 22:06:31 +1100 (EST) (envelope-from tim) Message-Id: <200112271106.fBRB6Vh43939@raven.robbins.dropbear.id.au> Date: Thu, 27 Dec 2001 22:06:31 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/33237: ftp(1) fails to fetch files via HTTP from name-based vhost Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 33237 >Category: bin >Synopsis: ftp(1) fails to fetch files via HTTP from name-based vhost >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Dec 27 03:10:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.4-STABLE i386 >Organization: >Environment: System: FreeBSD raven.robbins.dropbear.id.au 4.4-STABLE FreeBSD 4.4-STABLE #1: Thu Dec 20 19:34:48 EST 2001 root@raven.robbins.dropbear.id.au:/usr/obj/usr/src/sys/RAVEN i386 >Description: ftp(1) does not send a HTTP Host: header with requests, which causes 404 Not Found errors, or the wrong page to be retrieved when name-based virtual hosts are used. It's worth noting that the sourceforge download server uses name-based virtual hosts, so this could break a fair few downloads. fetch doesn't have this same problem, only ftp. >How-To-Repeat: ftp(1) from -STABLE: $ ftp.old -v http://www.phenoelit.de/irpas/irpas_0.9.tar.gz Requesting http://www.phenoelit.de/irpas/irpas_0.9.tar.gz ftp.old: Error retrieving file: 404 Not Found After applying patch below: $ ftp.new -v http://www.phenoelit.de/irpas/irpas_0.9.tar.gz Requesting http://www.phenoelit.de/irpas/irpas_0.9.tar.gz 100% |**************************************************| 178 KB 00:00 ETA Successfully retrieved file. >Fix: Send a Host: header containing the host portion from the URL. --- fetch.c.old Thu Dec 27 18:27:46 2001 +++ fetch.c Thu Dec 27 18:29:05 2001 @@ -280,8 +280,8 @@ printf("Requesting %s\n", origline); else printf("Requesting %s (via %s)\n", origline, proxyenv); - len = snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\n\r\n", - proxy ? "" : "/", path); + len = snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\nHost: %s\r\n\r\n", + proxy ? "" : "/", path, host); if (write(s, buf, len) < len) { warn("Writing HTTP request"); goto cleanup_url_get; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message