Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Dec 2001 22:06:31 +1100 (EST)
From:      "Tim J. Robbins" <tim@robbins.dropbear.id.au>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/33237: ftp(1) fails to fetch files via HTTP from name-based vhost
Message-ID:  <200112271106.fBRB6Vh43939@raven.robbins.dropbear.id.au>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200112271106.fBRB6Vh43939>