1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

Joe Halpin made the FTP code send 'QUIT' on the control connection before

it disconnects the TCP connection, like a good ftp client should!
This commit is contained in:
Daniel Stenberg 2004-02-27 07:08:37 +00:00
parent 1ceb77b4dc
commit 77268e0649
49 changed files with 76 additions and 10 deletions

View File

@ -2288,12 +2288,14 @@ CURLcode ftp_perform(struct connectdata *conn,
* parts etc as a wrapper to the actual DO function (ftp_perform).
*
* The input argument is already checked for validity.
*
* ftp->ctl_valid starts out as FALSE, and gets set to TRUE if we reach the
* end of the function.
*/
CURLcode Curl_ftp(struct connectdata *conn)
{
CURLcode retcode=CURLE_OK;
bool connected=0;
struct SessionHandle *data = conn->data;
struct FTP *ftp;
@ -2304,6 +2306,7 @@ CURLcode Curl_ftp(struct connectdata *conn)
/* the ftp struct is already inited in ftp_connect() */
ftp = conn->proto.ftp;
ftp->ctl_valid = FALSE;
conn->size = -1; /* make sure this is unknown at this point */
Curl_pgrsSetUploadCounter(data, 0);
@ -2386,6 +2389,7 @@ CURLcode Curl_ftp(struct connectdata *conn)
else
freedirs(ftp);
ftp->ctl_valid = TRUE;
return retcode;
}
@ -2452,11 +2456,13 @@ CURLcode Curl_ftp_quit(struct connectdata *conn)
{
ssize_t nread;
int ftpcode;
CURLcode ret;
CURLcode ret = CURLE_OK;
ret = Curl_ftpsendf(conn, "%s", "QUIT");
if(CURLE_OK == ret)
ret = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(conn->proto.ftp->ctl_valid) {
ret = Curl_ftpsendf(conn, "%s", "QUIT");
if(CURLE_OK == ret)
ret = Curl_GetFTPResponse(&nread, conn, &ftpcode);
}
return ret;
}
@ -2472,15 +2478,14 @@ CURLcode Curl_ftp_disconnect(struct connectdata *conn)
{
struct FTP *ftp= conn->proto.ftp;
#if 0
/* We cannot send quit unconditionally. If this connection is stale or
bad in any way, sending quit and waiting around here will make the
disconnect wait in vain and cause more problems than we need to.
Until fixed, we keep this #if 0'ed. To be fixed in 7.11.1. Stay tuned.
Curl_ftp_quit() will check the state of ftp->ctl_valid. If it's ok it
will try to send the QUIT command, otherwise it will just return.
*/
(void)Curl_ftp_quit(conn); /* ignore errors on the QUIT */
#endif
/* The FTP session may or may not have been allocated/setup at this point! */
if(ftp) {

View File

@ -258,6 +258,10 @@ struct FTP {
long response_time; /* When no timeout is given, this is the amount of
seconds we await for an FTP response. Initialized
in Curl_ftp_connect() */
bool ctl_valid; /* Tells Curl_ftp_quit() whether or not to do
anything. If the connection has timed out or
been closed, this should be FALSE when it gets
to Curl_ftp_quit() */
};
/****************************************************************************

View File

@ -43,5 +43,6 @@ PWD
EPSV
TYPE A
LIST
QUIT
</protocol>
</verify>

View File

@ -43,5 +43,6 @@ PWD
PORT 127,0,0,1,243,212
TYPE A
LIST
QUIT
</protocol>
</verify>

View File

@ -38,5 +38,6 @@ PASV
TYPE I
SIZE 102
RETR 102
QUIT
</protocol>
</verify>

View File

@ -40,5 +40,6 @@ PORT 127,0,0,1,246,33
TYPE I
SIZE 103
RETR 103
QUIT
</protocol>
</verify>

View File

@ -30,5 +30,6 @@ MDTM 103
TYPE I
SIZE 103
REST 0
QUIT
</protocol>
</verify>

View File

@ -38,5 +38,6 @@ PASV
TYPE A
SIZE 103
RETR 103
QUIT
</protocol>
</verify>

View File

@ -35,5 +35,6 @@ EPSV
TYPE A
SIZE 106
RETR 106
QUIT
</protocol>
</verify>

View File

@ -37,5 +37,6 @@ PWD
EPSV
TYPE I
STOR 107
QUIT
</protocol>
</verify>

View File

@ -38,6 +38,7 @@ CWD RETR
PORT 127,0,0,1,5,109
TYPE I
STOR 108
QUIT
</protocol>
<upload>
Moooooooooooo

View File

@ -32,6 +32,7 @@ PWD
EPSV
TYPE I
APPE 109
QUIT
</protocol>
<upload>
Moooooooooooo

View File

@ -39,5 +39,6 @@ TYPE I
SIZE 110
REST 20
RETR 110
QUIT
</protocol>
</verify>

View File

@ -32,5 +32,6 @@ PWD
EPSV
TYPE I
SIZE 111
QUIT
</protocol>
</verify>

View File

@ -31,6 +31,7 @@ PWD
EPSV
TYPE I
APPE 112
QUIT
</protocol>
<upload>
gonna upload

View File

@ -30,5 +30,6 @@ PASS curl_by_daniel@haxx.se
PWD
EPSV
PASV
QUIT
</protocol>
</verify>

View File

@ -32,5 +32,6 @@ REPLY PORT 314 bluah you f00l!
USER anonymous
PASS curl_by_daniel@haxx.se
PWD
QUIT
</protocol>
</verify>

View File

@ -31,5 +31,6 @@ PWD
EPSV
PASV
TYPE I
QUIT
</protocol>
</verify>

View File

@ -33,5 +33,6 @@ PASV
TYPE I
SIZE 118
RETR 118
QUIT
</protocol>
</verify>

View File

@ -35,5 +35,6 @@ PWD
TYPE I
SIZE 119
RETR 119
QUIT
</protocol>
</verify>

View File

@ -38,5 +38,6 @@ TYPE I
SIZE 120
RETR 120
DELE file
QUIT
</protocol>
</verify>

View File

@ -35,5 +35,6 @@ TYPE I
SIZE 121
RETR 121
DELE after_transfer
QUIT
</protocol>
</verify>

View File

@ -31,5 +31,6 @@ EPSV
PASV
TYPE I
SIZE 122
QUIT
</protocol>
</verify>

View File

@ -26,5 +26,6 @@ PASS curl_by_daniel@haxx.se
PWD
EPSV
TYPE I
QUIT
</protocol>
</verify>

View File

@ -33,5 +33,6 @@ PASV
TYPE I
SIZE 124
RETR 124
QUIT
</protocol>
</verify>

View File

@ -28,5 +28,6 @@ USER anonymous
PASS curl_by_daniel@haxx.se
PWD
CWD path
QUIT
</protocol>
</verify>

View File

@ -33,5 +33,6 @@ EPSV
TYPE I
SIZE 126
RETR 126
QUIT
</protocol>
</verify>

View File

@ -31,5 +31,6 @@ PASV
TYPE I
SIZE 127
RETR 127
QUIT
</protocol>
</verify>

View File

@ -33,6 +33,7 @@ PWD
EPSV
TYPE I
STOR 128
QUIT
</protocol>
<upload>
file

View File

@ -51,5 +51,6 @@ PWD
EPSV
TYPE A
LIST
QUIT
</protocol>
</verify>

View File

@ -51,5 +51,6 @@ PWD
EPSV
TYPE A
LIST
QUIT
</protocol>
</verify>

View File

@ -51,5 +51,6 @@ PWD
EPSV
TYPE A
LIST
QUIT
</protocol>
</verify>

View File

@ -51,5 +51,6 @@ PWD
EPSV
TYPE A
LIST
QUIT
</protocol>
</verify>

View File

@ -51,5 +51,6 @@ PWD
EPSV
TYPE A
LIST
QUIT
</protocol>
</verify>

View File

@ -38,5 +38,6 @@ TYPE I
SIZE 135
REST 4
RETR 135
QUIT
</protocol>
</verify>

View File

@ -28,5 +28,6 @@ EPSV
TYPE I
SIZE 136
RETR 136
QUIT
</protocol>
</verify>

View File

@ -33,5 +33,6 @@ EPSV
TYPE I
SIZE 137
RETR 137
QUIT
</protocol>
</verify>

View File

@ -36,5 +36,6 @@ EPSV
TYPE I
SIZE 138
RETR 138
QUIT
</protocol>
</verify>

View File

@ -33,5 +33,6 @@ EPSV
TYPE I
SIZE 139
RETR 139
QUIT
</protocol>
</verify>

View File

@ -28,5 +28,6 @@ PASS curl_by_daniel@haxx.se
PWD
CWD blalbla
MDTM 140
QUIT
</protocol>
</verify>

View File

@ -31,6 +31,7 @@ MDTM 141
TYPE I
SIZE 141
REST 0
QUIT
</protocol>
<stdout>
Last-Modified: Wed, 09 Apr 2003 10:26:59 GMT

View File

@ -30,5 +30,6 @@ EPSV
TYPE A
SIZE 143
RETR 143
QUIT
</protocol>
</verify>

View File

@ -35,5 +35,6 @@ PWD
PORT 127,0,0,1,243,212
TYPE A
NLST
QUIT
</protocol>
</verify>

View File

@ -38,5 +38,6 @@ PWD
PORT 127,0,0,1,243,212
TYPE A
NLST
QUIT
</protocol>
</verify>

View File

@ -42,5 +42,6 @@ EPSV
TYPE I
SIZE 146
RETR 146
QUIT
</protocol>
</verify>

View File

@ -44,5 +44,6 @@ EPSV
TYPE I
SIZE 147
RETR 147
QUIT
</protocol>
</verify>

View File

@ -37,5 +37,6 @@ PASS curl_by_daniel@haxx.se
PWD
CWD attempt
MKD attempt
QUIT
</protocol>
</verify>

View File

@ -39,6 +39,7 @@ CWD dir2
EPSV
TYPE I
STOR 148
QUIT
</protocol>
<file name="log/upload148">
send away this contents

View File

@ -44,4 +44,15 @@ upload
works?
</upload>
<protocol>
USER anonymous
PASS curl_by_daniel@haxx.se
PWD
EPSV
TYPE I
STOR 505
RNFR 505
RNTO 505-forreal
QUIT
</protocol>
</verify>