Added 'dont_check' to be set during an FTP operation if the final status

message is supposed to be ignored.
This commit is contained in:
Daniel Stenberg 2002-06-13 09:21:08 +00:00
parent cae555c977
commit 3c63e1d8d9
2 changed files with 23 additions and 15 deletions

View File

@ -637,9 +637,9 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
failf(data, "Received only partial file: %d bytes", *ftp->bytecountp); failf(data, "Received only partial file: %d bytes", *ftp->bytecountp);
return CURLE_PARTIAL_FILE; return CURLE_PARTIAL_FILE;
} }
else if(!conn->bits.resume_done && else if(!ftp->dont_check &&
!data->set.no_body && !*ftp->bytecountp &&
(!*ftp->bytecountp && (conn->size>0))) { (conn->size>0)) {
/* We consider this an error, but there's no true FTP error received /* We consider this an error, but there's no true FTP error received
why we need to continue to "read out" the server response too. why we need to continue to "read out" the server response too.
We don't want to leave a "waiting" server reply if we'll get told We don't want to leave a "waiting" server reply if we'll get told
@ -656,21 +656,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) { if(!data->set.no_body && !ftp->dont_check) {
/* 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;
if(!conn->bits.resume_done) { /* 226 Transfer complete, 250 Requested file action okay, completed. */
/* 226 Transfer complete, 250 Requested file action okay, completed. */ if((ftpcode != 226) && (ftpcode != 250)) {
if((ftpcode != 226) && (ftpcode != 250)) { failf(data, "server did not report OK, got %d", ftpcode);
failf(data, "server did not report OK, got %d", ftpcode); return CURLE_FTP_WRITE_ERROR;
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;
}
conn->bits.resume_done = FALSE; /* clean this for next connection */ conn->bits.resume_done = FALSE; /* clean this for next connection */
@ -1601,7 +1604,7 @@ CURLcode ftp_perform(struct connectdata *conn)
if(data->set.no_body) if(data->set.no_body)
/* don't transfer the data */ /* don't transfer the data */
; ftp->dont_check = 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 */
@ -1697,10 +1700,11 @@ 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 so that we won't get any error in /* Set resume done and dont_check so that we won't get any error
* Curl_ftp_done() because we didn't transfer the amount of bytes * in Curl_ftp_done() because we didn't transfer the amount of
* that the local file file obviously is */ * bytes that the local file file obviously is */
conn->bits.resume_done = TRUE; conn->bits.resume_done = TRUE;
ftp->dont_check = TRUE;
return CURLE_OK; return CURLE_OK;
} }
@ -1790,6 +1794,7 @@ 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 */ conn->bits.resume_done = TRUE; /* to prevent some error due to this */
ftp->dont_check = TRUE; /* dont check for successful transfer */
} }
if((data->set.ftp_list_only) || !ftp->file) { if((data->set.ftp_list_only) || !ftp->file) {
@ -1886,6 +1891,7 @@ CURLcode ftp_perform(struct connectdata *conn)
* because we didn't transfer the amount of bytes that the remote * because we didn't transfer the amount of bytes that the remote
* file obviously is */ * file obviously is */
conn->bits.resume_done = TRUE; conn->bits.resume_done = TRUE;
ftp->dont_check = TRUE;
return CURLE_OK; return CURLE_OK;
} }

View File

@ -179,7 +179,9 @@ struct FTP {
char *entrypath; /* the PWD reply when we logged on */ char *entrypath; /* the PWD reply when we logged on */
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)
file size and 226/250 status check */
}; };
/**************************************************************************** /****************************************************************************