struct FTP *ftp = conn->data->reqdata.proto.ftp;
struct SessionHandle *data = conn->data;
- if(ftp->no_transfer) {
+ if(ftp->transfer != FTPTRANSFER_BODY) {
/* doesn't transfer any data */
/* still possibly do PRE QUOTE jobs */
CURLcode result = CURLE_OK;
struct FTP *ftp = conn->data->reqdata.proto.ftp;
- if(ftp->no_transfer && ftp->file) {
+ if((ftp->transfer != FTPTRANSFER_BODY) && ftp->file) {
/* if a "head"-like request is being made (on a file) */
/* Determine if server can respond to REST command and therefore
CURLcode result = CURLE_OK;
struct FTP *ftp = conn->data->reqdata.proto.ftp;
- if(ftp->no_transfer && ftp->file) {
+ if((ftp->transfer == FTPTRANSFER_INFO) && ftp->file) {
/* if a "head"-like request is being made (on a file) */
/* we know ftp->file is a valid pointer to a file name */
/* If we have selected NOBODY and HEADER, it means that we only want file
information. Which in FTP can't be much more than the file size and
date. */
- if(conn->bits.no_body && data->set.include_header && ftp->file &&
+ if(conn->bits.no_body && ftp->file &&
ftp_need_type(conn, data->set.prefer_ascii)) {
/* The SIZE command is _not_ RFC 959 specified, and therefor many servers
may not support it! It is however the only way we have to get a file's
size! */
- ftp->no_transfer = TRUE; /* this means no actual transfer will be made */
+ ftp->transfer = FTPTRANSFER_INFO;
+ /* this means no actual transfer will be made */
/* Some servers return different sizes for different modes, and thus we
must set the proper type before we check the size */
/* no data to transfer */
result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
- /* Set no_transfer so that we won't get any error in
+ /* Set ->transfer so that we won't get any error in
* Curl_ftp_done() because we didn't transfer anything! */
- ftp->no_transfer = TRUE;
+ ftp->transfer = FTPTRANSFER_NONE;
state(conn, FTP_STOP);
return CURLE_OK;
result = ftp_state_cwd(conn);
break;
case FTP_RETR_PREQUOTE:
- if (ftp->no_transfer)
+ if (ftp->transfer != FTPTRANSFER_BODY)
state(conn, FTP_STOP);
else {
NBFTPSENDF(conn, "SIZE %s", ftp->file);
we "emulate" a HTTP-style header in our output. */
if(conn->bits.no_body &&
- data->set.include_header &&
ftp->file &&
data->set.get_filetime &&
(data->info.filetime>=0) ) {
default:
if(data->info.filetime <= data->set.timevalue) {
infof(data, "The requested document is not new enough\n");
- ftp->no_transfer = TRUE; /* mark this to not transfer data */
+ ftp->transfer = FTPTRANSFER_NONE; /* mark this to not transfer data */
state(conn, FTP_STOP);
return CURLE_OK;
}
case CURL_TIMECOND_IFUNMODSINCE:
if(data->info.filetime > data->set.timevalue) {
infof(data, "The requested document is not old enough\n");
- ftp->no_transfer = TRUE; /* mark this to not transfer data */
+ ftp->transfer = FTPTRANSFER_NONE; /* mark this to not transfer data */
state(conn, FTP_STOP);
return CURLE_OK;
}
result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
infof(data, "File already completely downloaded\n");
- /* Set no_transfer so that we won't get any error in Curl_ftp_done()
+ /* Set ->transfer so that we won't get any error in Curl_ftp_done()
* because we didn't transfer the any file */
- ftp->no_transfer = TRUE;
+ ftp->transfer = FTPTRANSFER_NONE;
state(conn, FTP_STOP);
return CURLE_OK;
}
else {
if((instate == FTP_LIST) && (ftpcode == 450)) {
/* simply no matching files in the dir listing */
- ftp->no_transfer = TRUE; /* don't download anything */
+ ftp->transfer = FTPTRANSFER_NONE; /* don't download anything */
state(conn, FTP_STOP); /* this phase is over */
}
else {
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
- if(!ftp->no_transfer && !status && !premature) {
+ if((ftp->transfer == FTPTRANSFER_BODY) && !status && !premature) {
/*
* Let's see what the server says about the transfer we just performed,
* but lower the timeout as sometimes this connection has died while the
if((-1 != data->set.infilesize) &&
(data->set.infilesize != *ftp->bytecountp) &&
!data->set.crlf &&
- !ftp->no_transfer) {
+ (ftp->transfer == FTPTRANSFER_BODY)) {
failf(data, "Uploaded unaligned file size (%" FORMAT_OFF_T
" out of %" FORMAT_OFF_T " bytes)",
*ftp->bytecountp, data->set.infilesize);
}
/* clear these for next connection */
- ftp->no_transfer = FALSE;
+ ftp->transfer = FTPTRANSFER_BODY;
ftpc->dont_check = FALSE;
/* Send any post-transfer QUOTE strings? */
DEBUGF(infof(data, "DO-MORE phase starts\n"));
- if(!ftp->no_transfer) {
- /* a transfer is about to take place */
+ if(ftp->transfer <= FTPTRANSFER_INFO) {
+ /* a transfer is about to take place, or if not a file name was given
+ so we'll do a SIZE on it later and then we need the right TYPE first */
if(data->set.upload) {
- result = ftp_nb_type(conn, data->set.prefer_ascii,
- FTP_STOR_TYPE);
+ result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_STOR_TYPE);
if (result)
return result;
}
result = ftp_range(conn);
if(result)
;
- else if((data->set.ftp_list_only) || !ftp->file) {
+ else if(data->set.ftp_list_only || !ftp->file) {
/* The specified path ends with a slash, and therefore we think this
is a directory that is requested, use LIST. But before that we
need to set ASCII transfer mode. */
- result = ftp_nb_type(conn, 1, FTP_LIST_TYPE);
- if (result)
- return result;
+
+ /* But only if a body transfer was requested. */
+ if(ftp->transfer == FTPTRANSFER_BODY) {
+ result = ftp_nb_type(conn, 1, FTP_LIST_TYPE);
+ if (result)
+ return result;
+ }
+ /* otherwise just fall through */
}
else {
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_RETR_TYPE);
result = ftp_easy_statemach(conn);
}
- if(ftp->no_transfer)
+ if(ftp->transfer != FTPTRANSFER_BODY)
/* no data to transfer. FIX: it feels like a kludge to have this here
too! */
result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
if(conn->bits.no_body) {
/* requested no body means no transfer... */
struct FTP *ftp = conn->data->reqdata.proto.ftp;
- ftp->no_transfer = TRUE;
+ ftp->transfer = FTPTRANSFER_INFO;
}
ftp->file=NULL; /* instead of point to a zero byte, we make it a NULL
pointer */
- if(data->set.upload && !ftp->file && !ftp->no_transfer) {
+ if(data->set.upload && !ftp->file && (ftp->transfer == FTPTRANSFER_BODY)) {
/* We need a file name when uploading. Return error! */
failf(data, "Uploading to a URL without a file name!");
return CURLE_URL_MALFORMAT;
return result;
}
- if(ftp->no_transfer)
+ if(ftp->transfer != FTPTRANSFER_BODY)
/* no data to transfer */
result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
else if(!connected)