aboutsummaryrefslogtreecommitdiff
path: root/lib/ftp.c
diff options
context:
space:
mode:
authorKurt Fankhauser <kurtbutfrank@gmail.com>2015-10-23 14:57:30 +0200
committerDaniel Stenberg <daniel@haxx.se>2015-10-23 14:57:30 +0200
commit529f9310b1febcd3626aefbc598032572efb248a (patch)
treeb81bc965fd7ea0332f8b48251f2ecbc1c5fa7784 /lib/ftp.c
parentb1199def8c214163a86c0afd405a9f93aa7d2007 (diff)
ftp: allow CURLOPT_IGNORE_CONTENT_LENGTH to ignore size
This allows FTP transfers with growing (or shrinking) files without causing a transfer error. Closes #480
Diffstat (limited to 'lib/ftp.c')
-rw-r--r--lib/ftp.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 639a063ea..21db56c8e 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -1790,8 +1790,20 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
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;