Here is the patch that allows setting CURLOPT_IGNORE_CONTENT_LENGTH to
prevent curl from requesting the file size from the ftp server.  The result
is the connection is kept open until the server closes it when the file is
completely transferred.

--- ftp.c       2015-09-23 17:38:17.085173695 -0700
+++ ftp.c.new   2015-09-23 17:55:53.583311750 -0700
@@ -1790,8 +1790,20 @@
           result = ftp_state_retr(conn, ftpc->known_filesize);
         }
         else {
-          PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file);
-          state(conn, FTP_RETR_SIZE);
+          if (data->set.ignorecl) {
+            /* This code is to support download of growing files.  It
prevents
+               the state machine from requesting the file size from the
server.  With
+               an unknown file size the download continues until the
server terminates it,
+               otherwise the client stops if the received byte count
exceeds the reported
+               file size.
+               Set option CURLOPT_IGNORE_CONTENT_LENGTH to 1 to enable
this behavior.*/
+            PPSENDF(&ftpc->pp, "RETR %s", ftpc->file);
+            state(conn, FTP_RETR);
+          }
+          else {
+            PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file);
+            state(conn, FTP_RETR_SIZE);
+          }
         }
       }
       break;


On Tue, Mar 3, 2015 at 11:43 PM, Daniel Stenberg <[email protected]> wrote:

> On Tue, 3 Mar 2015, Kurt Fankhauser wrote:
>
> It looks like I can use the CURLOPT_IGNORE_CONTENT_LENGTH to control this
>> behavior with a small change to ftp_state_quote():
>>
>
> Yes, that probably makes it in the client side. You still need to make
> sure the server do the necessary magic if the client reads to the end of
> the file while the uploading client is still in progress...
>
> --
>
>  / daniel.haxx.se
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  http://curl.haxx.se/mail/etiquette.html
>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to