aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-11-10 13:42:45 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-11-10 13:42:45 +0000
commit4035543763136642dfdbe9e63c98018b9711de34 (patch)
treeb49e131c6735194e6fa0b8f9c412ee960e401b32 /lib
parent920579ba1189de99f2242acf102f8b64ee00ee0b (diff)
set type before checking --head size, as the type may cause the server
to return different sizes
Diffstat (limited to 'lib')
-rw-r--r--lib/ftp.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 88e7faf15..4224c533a 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -661,6 +661,23 @@ CURLcode _ftp(struct connectdata *conn)
may not support it! It is however the only way we have to get a file's
size! */
int filesize;
+
+ /* Some servers return different sizes for different modes, and thus we
+ must set the proper type before we check the size */
+ ftpsendf(data->firstsocket, conn, "TYPE %s",
+ (data->bits.ftp_ascii)?"A":"I");
+
+ nread = GetLastResponse(data->firstsocket, buf, conn);
+ if(nread < 0)
+ return CURLE_OPERATION_TIMEOUTED;
+
+ if(strncmp(buf, "200", 3)) {
+ failf(data, "Couldn't set %s mode",
+ (data->bits.ftp_ascii)?"ASCII":"binary");
+ return (data->bits.ftp_ascii)? CURLE_FTP_COULDNT_SET_ASCII:
+ CURLE_FTP_COULDNT_SET_BINARY;
+ }
+
ftpsendf(data->firstsocket, conn, "SIZE %s", ftp->file);
nread = GetLastResponse(data->firstsocket, buf, conn);