Subject: bin/15415: ftp(1) would fail to fetch using HTTP.
To: None <>
From: Takahiro Kambe <>
List: netbsd-bugs
Date: 01/30/2002 01:34:20
>Number:         15415
>Category:       bin
>Synopsis:       ftp(1) would fail to fetch using HTTP.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 29 08:35:00 PST 2002
>Originator:     Takahiro Kambe
>Release:        NetBSD 1.5ZA
System: NetBSD 1.5ZA NetBSD 1.5ZA (FIVA20X) #111: Sun Jan 27 01:03:00 JST 2002 i386
Architecture: i386
Machine: i386
	ftp(1) would fail to fetch using HTTP.  This is really a HTTP
	server's problem, not ftp(1).  I found that some HTTP server
	return "404 Not found" error with sending "Host" HTTP request
	header with:


	But, the server works fine with:


	Yes, it seems problem that adding default HTTP port explicitly
	though HTTP standard allow it.
	Try to do:

	% ftp

	This server returns "Server: Zeus/3.4" in its respose header.
	So, I've report to technical contact of (since isn't available) and
	Below ad hoc patch seems to work fine.

--- usr.bin/ftp/fetch.c.orig	Fri Dec 28 10:07:27 2001
+++ usr.bin/ftp/fetch.c	Wed Jan 30 01:22:43 2002
@@ -730,10 +730,14 @@
 				    (p = strchr(h, '%')) != NULL) {
 					*p = '\0';
-				fprintf(fin, "Host: [%s]:%d\r\n", h, portnum);
+				fprintf(fin, "Host: [%s]", h);
 			} else
-				fprintf(fin, "Host: %s:%d\r\n", host, portnum);
+				fprintf(fin, "Host: %s", host);
+			if (portnum != HTTP_PORT) {
+				fprintf(fin, "%d", portnum);
+			}
+			fputs("\r\n", fin);
 			fprintf(fin, "Accept: */*\r\n");
 			fprintf(fin, "Connection: close\r\n");
 			if (restart_point) {