Subject: bin/8828: ftp(1) needs to send HTTP/1.1 Host: header
To: None <gnats-bugs@gnats.netbsd.org>
From: None <mike@skew.org>
List: netbsd-bugs
Date: 11/19/1999 14:09:41
>Number:         8828
>Category:       bin
>Synopsis:       ftp(1) needs to send HTTP/1.1 Host: header
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 19 14:09:00 1999
>Last-Modified:
>Originator:     Mike Brown
>Organization:
>Release:        actually, I'm using FreeBSD 3.2-RELEASE
>Environment:
FreeBSD chillout.skew.org 3.2-RELEASE FreeBSD 3.2-RELEASE #0: Sat Aug  7 10:25:47 MDT 1999     mike@chillout.skew.org:/usr/src/sys/compile/chillout  i386
>Description:
ftp(1) does not send the HTTP/1.1 Host: header when retrieving from an http:// URL. This header was implemented on HTTP/1.0 servers for virtual hosting purposes and is commonly sent by clients as part of an HTTP/1.0 request. If you attempt to access an HTTP server when you only know its IP number, it will attempt to obtain the document from a default document root. Virtual hosting servers need to see the Host: header in order to know which root dir to use.

>How-To-Repeat:
*.apache.org sites all share the same IP number, but the document root for each site varies.

Therefore, this fails:
ftp http://xml.apache.org/dist/LICENSE.txt
>Fix:
*** fetch.c.old Tue Dec 16 01:58:15 1997
--- fetch.c     Fri Nov 19 14:45:23 1999
***************
*** 236,243 ****
                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);
        if (write(s, buf, len) < len) {
                warn("Writing HTTP request");
                goto cleanup_url_get;
--- 236,243 ----
                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\nHost: %s\r\n\r\n",
!           proxy ? "" : "/", path, host);
        if (write(s, buf, len) < len) {
                warn("Writing HTTP request");
                goto cleanup_url_get;



>Audit-Trail:
>Unformatted: