aboutsummaryrefslogtreecommitdiff
path: root/lib/ftp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-08-31 12:04:55 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-08-31 12:04:55 +0000
commit5e7cd528b08d6c57220cfe1a307a0d92c02daca2 (patch)
treebe600f553bf5a576b3d67c9e33164621f6b6f719 /lib/ftp.c
parent60eab89f10319fed1b5c6174a301b25f514c72b1 (diff)
made -I (size info only) work for ftp again
Diffstat (limited to 'lib/ftp.c')
-rw-r--r--lib/ftp.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index db64c63c6..71262012b 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -471,7 +471,7 @@ CURLcode ftp_done(struct connectdata *conn)
failf(data, "Received only partial file");
return CURLE_PARTIAL_FILE;
}
- else if(0 == *ftp->bytecountp) {
+ else if(!data->bits.no_body && (0 == *ftp->bytecountp)) {
failf(data, "No data was received!");
return CURLE_FTP_COULDNT_RETR_FILE;
}
@@ -479,17 +479,19 @@ CURLcode ftp_done(struct connectdata *conn)
/* shut down the socket to inform the server we're done */
sclose(data->secondarysocket);
data->secondarysocket = -1;
-
- /* now let's see what the server says about the transfer we
- just performed: */
- nread = GetLastResponse(data->firstsocket, buf, conn);
- if(nread < 0)
- return CURLE_OPERATION_TIMEOUTED;
- /* 226 Transfer complete, 250 Requested file action okay, completed. */
- if(!strncmp(buf, "226", 3) && !strncmp(buf, "250", 3)) {
- failf(data, "%s", buf+4);
- return CURLE_FTP_WRITE_ERROR;
+ if(!data->bits.no_body) {
+ /* now let's see what the server says about the transfer we
+ just performed: */
+ nread = GetLastResponse(data->firstsocket, buf, conn);
+ if(nread < 0)
+ return CURLE_OPERATION_TIMEOUTED;
+
+ /* 226 Transfer complete, 250 Requested file action okay, completed. */
+ if(!strncmp(buf, "226", 3) && !strncmp(buf, "250", 3)) {
+ failf(data, "%s", buf+4);
+ return CURLE_FTP_WRITE_ERROR;
+ }
}
/* Send any post-transfer QUOTE strings? */
@@ -572,6 +574,19 @@ CURLcode _ftp(struct connectdata *conn)
}
}
+ /* change directory first! */
+ if(ftp->dir && ftp->dir[0]) {
+ sendf(data->firstsocket, data, "CWD %s\r\n", ftp->dir);
+ nread = GetLastResponse(data->firstsocket, buf, conn);
+ if(nread < 0)
+ return CURLE_OPERATION_TIMEOUTED;
+
+ if(strncmp(buf, "250", 3)) {
+ failf(data, "Couldn't change to directory %s", ftp->dir);
+ return CURLE_FTP_ACCESS_DENIED;
+ }
+ }
+
/* If we have selected NOBODY, it means that we only want file information.
Which in FTP can't be much more than the file size! */
if(data->bits.no_body) {
@@ -851,20 +866,6 @@ CURLcode _ftp(struct connectdata *conn)
/* we have the (new) data connection ready */
infof(data, "Connected!\n");
- /* change directory first */
-
- if(ftp->dir && ftp->dir[0]) {
- sendf(data->firstsocket, data, "CWD %s\r\n", ftp->dir);
- nread = GetLastResponse(data->firstsocket, buf, conn);
- if(nread < 0)
- return CURLE_OPERATION_TIMEOUTED;
-
- if(strncmp(buf, "250", 3)) {
- failf(data, "Couldn't change to directory %s", ftp->dir);
- return CURLE_FTP_ACCESS_DENIED;
- }
- }
-
if(data->bits.upload) {
/* Set type to binary (unless specified ASCII) */