Subject: bin/15415: ftp(1) would fail to fetch using HTTP.
To: None <gnats-bugs@gnats.netbsd.org>
From: Takahiro Kambe <taca@sky.yamashina.kyoto.jp>
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
>Closed-Date:
>Last-Modified:
>Originator:     Takahiro Kambe
>Release:        NetBSD 1.5ZA
>Organization:
	
>Environment:
	
	
System: NetBSD edge.sky.yamashina.kyoto.jp 1.5ZA NetBSD 1.5ZA (FIVA20X) #111: Sun Jan 27 01:03:00 JST 2002 taca@edge.sky.yamashina.kyoto.jp:/usr/src/sys/arch/i386/compile/FIVA20X i386
Architecture: i386
Machine: i386
>Description:
	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:

		Host: www.example.net:80

	But, the server works fine with:

		Host: www.example.net

	Yes, it seems problem that adding default HTTP port explicitly
	though HTTP standard allow it.
>How-To-Repeat:
	Try to do:

	% ftp http://www2a.biglobe.ne.jp/~seki/ruby/drb-1.3.4.2.tar.gz

	This server returns "Server: Zeus/3.4" in its respose header.
	So, I've report to technical contact of biglobe.ne.jp (since
	webmaster@biglobe.ne.jp isn't available) and
	support@japan-zeus.com.
>Fix:
	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);
 				free(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) {
>Release-Note:
>Audit-Trail:
>Unformatted: