diff options
author | Daniel Stenberg <daniel@haxx.se> | 2010-01-01 14:44:44 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2010-01-01 14:44:44 +0000 |
commit | 605bbfc4c0fa838f50bf9d18e69e417168f524c0 (patch) | |
tree | 405fa3f29adea6bacbaad6b1edf8ad8f9e5b718a /lib/ftp.c | |
parent | 42d365f199f9637820de4ecdee21bc7d4668f138 (diff) |
- Ingmar Runge enhanced libcurl's FTP engine to support the PRET command. This
command is a special "hack" used by the drftpd server, but even though it is
a custom extension I've deemed it fine to add to libcurl since this server
seems to survive and people keep using it and want libcurl to support
it. The new libcurl option is named CURLOPT_FTP_USE_PRET, and it is also
usable from the curl tool with --ftp-pret. Using this option on a server
that doesn't support this command will make libcurl fail.
Diffstat (limited to 'lib/ftp.c')
-rw-r--r-- | lib/ftp.c | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -565,6 +565,7 @@ static void state(struct connectdata *conn, "REST", "RETR_REST", "PORT", + "PRET", "PASV", "LIST", "RETR", @@ -1090,7 +1091,25 @@ static CURLcode ftp_state_post_rest(struct connectdata *conn) } else { /* We have chosen (this is default) to use the PASV (or similar) command */ - result = ftp_state_use_pasv(conn); + if(data->set.ftp_use_pret) { + /* The user has requested that we send a PRET command + to prepare the server for the upcoming PASV */ + if(!conn->proto.ftpc.file) { + PPSENDF(&conn->proto.ftpc.pp, "PRET %s", data->set.str[STRING_CUSTOMREQUEST]? + data->set.str[STRING_CUSTOMREQUEST]: + (data->set.ftp_list_only?"NLST":"LIST")); + } + else if(data->set.upload) { + PPSENDF(&conn->proto.ftpc.pp, "PRET STOR %s", conn->proto.ftpc.file); + } + else { + PPSENDF(&conn->proto.ftpc.pp, "PRET RETR %s", conn->proto.ftpc.file); + } + state(conn, FTP_PRET); + } + else { + result = ftp_state_use_pasv(conn); + } } return result; } @@ -2710,6 +2729,15 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) result = ftp_state_rest_resp(conn, ftpcode, ftpc->state); break; + case FTP_PRET: + if(ftpcode != 200) { + /* there only is this one standard OK return code. */ + failf(data, "PRET command not accepted: %03d", ftpcode); + return CURLE_FTP_PRET_FAILED; + } + result = ftp_state_use_pasv(conn); + break; + case FTP_PASV: result = ftp_state_pasv_resp(conn, ftpcode); break; |