On Sun, 2003-06-15 at 20:47, Ville Skytt� wrote:

> According to RFC 959 (4.1.3), ABOR after a successful transfer should be
> non-intrusive.  Additionally, Net::FTP::dataconn does a close (only)
> anyway if the transfer was already completed.  Fix attached, which also
> makes the HEAD response code special case obsolete.

Ditching the HEAD special case altogether seems to cause unwanted side
effects.  Attached is a revised patch.  And here are some test cases to
play around with:

$ HEAD ftp://ftp.wu-ftpd.org/pub/README
$ HEAD ftp://ftp.wisdom.weizmann.ac.il/pub/ls-lR.gz

-- 
\/ille Skytt�
ville.skytta at iki.fi

Index: lib/LWP/Protocol/ftp.pm
===================================================================
RCS file: /cvsroot/libwww-perl/lwp5/lib/LWP/Protocol/ftp.pm,v
retrieving revision 1.31
diff -a -u -r1.31 ftp.pm
--- lib/LWP/Protocol/ftp.pm	26 Oct 2001 20:13:20 -0000	1.31
+++ lib/LWP/Protocol/ftp.pm	15 Jun 2003 20:22:27 -0000
@@ -315,9 +315,13 @@
 		    return \$content;
 		} );
 	    }
-	    unless ($data->close) {
-		# Something did not work too well
-		if ($method ne 'HEAD') {
+	    # abort is needed for HEAD, it's == close if the transfer has
+	    # already completed.
+	    unless ($data->abort) {
+		# Something did not work too well.  Note that we treat
+		# responses to abort() with code 0 in case of HEAD as ok
+		# (at least wu-ftpd 2.6.1(1) does that).
+		if ($method ne 'HEAD' || $ftp->code != 0) {
 		    $response->code(&HTTP::Status::RC_INTERNAL_SERVER_ERROR);
 		    $response->message("FTP close response: " . $ftp->code .
 				       " " . $ftp->message);

Reply via email to