cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Warkaround for double FTP response

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 16 Dec 2009 17:46:10 +0100 (CET)

On Wed, 16 Dec 2009, Yastrebkov Dmitry wrote:

> After recieving APPE command my server send double response and curl
> can't operate with it.

Wow, that's so... broken.

> Curl get first response, extract response code 150, write "server did
> not report OK, got 150" and return error
> But in second response string server send "226 File received ok." That
> mean transfer succeed.

That's the _third_ response string. The problem is that the server sends two
150 and one 226, when it should've sent one 150 and one 226.

> How can I get last response or how can I flush response queue?

I assume one plausible way is to make the *_store_resp() function see if the
response code after a transfer is 150 and just pretend it didn't happen,
remain in the same state and wait for the next response code to trigger the
same function call again. Does it do the same after a STOR or is it just for
APPE?

A test would be something like this:

Index: lib/ftp.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/ftp.c,v
retrieving revision 1.535
diff -u -r1.535 ftp.c
--- lib/ftp.c 14 Dec 2009 14:02:43 -0000 1.535
+++ lib/ftp.c 16 Dec 2009 16:44:53 -0000
@@ -2046,6 +2046,9 @@
    struct SessionHandle *data = conn->data;
    struct FTP *ftp = data->state.proto.ftp;

+ if(ftpcode == 150)
+ return CURLE_OK;
+
    if(ftpcode>=400) {
      failf(data, "Failed FTP upload: %0d", ftpcode);
      /* oops, we never close the sockets! */

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2009-12-16