1
0
mirror of https://github.com/moparisthebest/curl synced 2024-10-31 15:45:12 -04:00

Remade the FTP not-check status line and not-attempt-to-read-status-line

variables, conditions and things.
This commit is contained in:
Daniel Stenberg 2002-06-14 06:57:00 +00:00
parent 559dc503c2
commit 93f1784526
2 changed files with 25 additions and 31 deletions

View File

@ -23,7 +23,6 @@
#include "setup.h" #include "setup.h"
/* MN 06/07/02 */
#ifndef CURL_DISABLE_FTP #ifndef CURL_DISABLE_FTP
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -656,26 +655,24 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
sclose(conn->secondarysocket); sclose(conn->secondarysocket);
conn->secondarysocket = -1; conn->secondarysocket = -1;
if(!data->set.no_body && !ftp->dont_check) { if(!ftp->no_transfer) {
/* now let's see what the server says about the transfer we just /* now let's see what the server says about the transfer we just
performed: */ performed: */
nread = Curl_GetFTPResponse(buf, conn, &ftpcode); nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0) if(nread < 0)
return CURLE_OPERATION_TIMEOUTED; return CURLE_OPERATION_TIMEOUTED;
/* 226 Transfer complete, 250 Requested file action okay, completed. */ if(!ftp->dont_check) {
if((ftpcode != 226) && (ftpcode != 250)) { /* 226 Transfer complete, 250 Requested file action okay, completed. */
failf(data, "server did not report OK, got %d", ftpcode); if((ftpcode != 226) && (ftpcode != 250)) {
return CURLE_FTP_WRITE_ERROR; failf(data, "server did not report OK, got %d", ftpcode);
return CURLE_FTP_WRITE_ERROR;
}
} }
} }
if(ftp->dont_check)
/* if we don't check, we can't re-use this connection as it leaves the
control connection in a weird status */
conn->bits.close = TRUE;
/* reset these for next connection */ /* clear these for next connection */
conn->bits.resume_done = FALSE; ftp->no_transfer = FALSE;
ftp->dont_check = FALSE; ftp->dont_check = FALSE;
/* Send any post-transfer QUOTE strings? */ /* Send any post-transfer QUOTE strings? */
@ -1563,6 +1560,8 @@ CURLcode ftp_perform(struct connectdata *conn)
size! */ size! */
ssize_t filesize; ssize_t filesize;
ftp->no_transfer = TRUE; /* this means no actual transfer is made */
/* Some servers return different sizes for different modes, and thus we /* Some servers return different sizes for different modes, and thus we
must set the proper type before we check the size */ must set the proper type before we check the size */
result = ftp_transfertype(conn, data->set.ftp_ascii); result = ftp_transfertype(conn, data->set.ftp_ascii);
@ -1604,8 +1603,8 @@ CURLcode ftp_perform(struct connectdata *conn)
} }
if(data->set.no_body) if(data->set.no_body)
/* don't transfer the data */ /* doesn't really transfer any data */
; ftp->no_transfer = TRUE;
/* Get us a second connection up and connected */ /* Get us a second connection up and connected */
else if(data->set.ftp_use_port) { else if(data->set.ftp_use_port) {
/* We have chosen to use the PORT command */ /* We have chosen to use the PORT command */
@ -1701,11 +1700,9 @@ CURLcode ftp_perform(struct connectdata *conn)
/* no data to transfer */ /* no data to transfer */
result=Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL); result=Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
/* Set resume done and dont_check so that we won't get any error /* Set no_transfer so that we won't get any error in
* in Curl_ftp_done() because we didn't transfer the amount of * Curl_ftp_done() because we didn't transfer anything! */
* bytes that the local file file obviously is */ ftp->no_transfer = TRUE;
conn->bits.resume_done = TRUE;
ftp->dont_check = TRUE;
return CURLE_OK; return CURLE_OK;
} }
@ -1794,7 +1791,6 @@ CURLcode ftp_perform(struct connectdata *conn)
} }
infof(data, "range-download from %d to %d, totally %d bytes\n", infof(data, "range-download from %d to %d, totally %d bytes\n",
from, to, totalsize); from, to, totalsize);
conn->bits.resume_done = TRUE; /* to prevent some error due to this */
ftp->dont_check = TRUE; /* dont check for successful transfer */ ftp->dont_check = TRUE; /* dont check for successful transfer */
} }
@ -1888,12 +1884,9 @@ CURLcode ftp_perform(struct connectdata *conn)
result=Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL); result=Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
infof(data, "File already completely downloaded\n"); infof(data, "File already completely downloaded\n");
/* Set resume done so that we won't get any error in Curl_ftp_done() /* Set no_transfer so that we won't get any error in Curl_ftp_done()
* because we didn't transfer the amount of bytes that the remote * because we didn't transfer the any file */
* file obviously is */ ftp->no_transfer = TRUE;
conn->bits.resume_done = TRUE;
ftp->dont_check = TRUE;
return CURLE_OK; return CURLE_OK;
} }

View File

@ -180,8 +180,12 @@ struct FTP {
char *cache; /* data cache between getresponse()-calls */ char *cache; /* data cache between getresponse()-calls */
size_t cache_size; /* size of cache in bytes */ size_t cache_size; /* size of cache in bytes */
bool dont_check; /* set to TRUE to prevent the final (post-transfer) bool dont_check; /* Set to TRUE to prevent the final (post-transfer)
file size and 226/250 status check */ file size and 226/250 status check. It should still
read the line, just ignore the result. */
bool no_transfer; /* nothing was transfered, (possibly because a resumed
transfer already was complete) */
}; };
/**************************************************************************** /****************************************************************************
@ -204,9 +208,6 @@ struct ConnectBits {
bool use_range; bool use_range;
bool rangestringalloc; /* the range string is malloc()'ed */ bool rangestringalloc; /* the range string is malloc()'ed */
bool resume_done; /* nothing was transfered, resumed transfer already
complete */
}; };
/* /*