mirror of
https://github.com/curl/curl.git
synced 2026-08-26 19:23:32 +03:00
- 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.
This commit is contained in:
parent
42d365f199
commit
605bbfc4c0
15 changed files with 186 additions and 5 deletions
30
lib/ftp.c
30
lib/ftp.c
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue