Subject: bin/9096: ftp(1) does not like what apache 1.3.9 sends (chunked encoding)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itojun@itojun.org>
List: netbsd-bugs
Date: 01/01/2000 05:48:57
>Number:         9096
>Category:       bin
>Synopsis:       ftp(1) does not like what apache 1.3.9 sends (chunked encoding)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Jan  1 05:48:00 2000
>Last-Modified:
>Originator:     Jun-ichiro itojun Hagino
>Organization:
	itojun.org
>Release:        1.4.1, current
>Environment:
System: NetBSD lychee.itojun.org 1.4.1 NetBSD 1.4.1 (LYCHEE.v6) #460: Fri Dec 31 01:31:37 JST 1999 itojun@lychee.itojun.org:/export/home/itojun/k/kame/netbsd/sys/arch/i386/compile/LYCHEE.v6 i386


>Description:
	apache 1.3.9 has a bug in chunked encoding, and ftp(1) does not
	forgive it.
	if you try to access http://mine.kame.net/~sakane/diary/ by using
	ftp(1), ftp(1) will bark "Unexpected data following chunksize" and exit.

	This is because apache 1.3.9 transmits a space after chunksize (hex
	number, "chunk-size".

HTTP/1.1 200 OK
Date: Sat, 01 Jan 2000 13:03:22 GMT
Server: Apache/1.3.9 (Unix)
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

b4 	<--- trailing space on this line


	from rfc2616, apache 1.3.9 is wrong and ftp(1) is correct.

3.6.1 Chunked Transfer Coding

       Chunked-Body   = *chunk
                        last-chunk
                        trailer
                        CRLF

       chunk          = chunk-size [ chunk-extension ] CRLF
                        chunk-data CRLF
       chunk-size     = 1*HEX
       last-chunk     = 1*("0") [ chunk-extension ] CRLF

       chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
       chunk-ext-name = token
       chunk-ext-val  = token | quoted-string
       chunk-data     = chunk-size(OCTET)
       trailer        = *(entity-header CRLF)

>How-To-Repeat:
	try
	% ftp -d -v -o - http://mine.kame.net/~sakane/diary/ >/dev/null
>Fix:
	1. apache 1.3.9 should be fixed.
	2. due to wide install base of apache 1.3.9, it may be better for
	   ftp(1) to be forgiving about it, or ftp(1) should try to fall back
	   to HTTP/1.0?  I'm not sure.
>Audit-Trail:
>Unformatted: