cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: should it work?

From: Armel Asselin <asselin.armel_at_wanadoo.fr>
Date: Tue, 8 Aug 2006 11:51:46 +0200

>I'm trying to do the following:
>- I want to profit from libcurl mechanic to make the CWD right to a
>directory and then I want to only do a MKD / >DELE / RMD command.
>- to do that I put the parent directory url of the item that I want to
>operate on as CURLOPT_URL
>- I put CULROPT_NOBODY = 1
>- I use a POST QUOTE with my command (e.g. MKD My Folder)
>- it issues exactly the wanted commands fomr a pure FTP point of view
>(checked the logs) and it works.
>
>but it hangs times to times, particularly when already in the right
>directory (i.e. the second list of commands hang). It >seems that the
>problem come from the fact that the "start" of the work should at least
>send some commands so as to >have something to wait for... but it sends
>nothing so that the select( ) before multi_perform( ) always fail with
>timeout, >the write part of the socket is not returned by multi_select( ).
>Also, at the exact time of the start of the command >Curl_select on the
>socket returns 0 (meaning that the socket is not ready, logically it go out
>of the initial DO phasis). but >it never reach the DOING phasis.
>
>should i do my stuff differently? how can I do that keeping the cool
>behaviour of libcurl wrt to the CWD commands?
in fact... POSTQUOTE stuff is never sent (it is used only for easy / third
party oriented stuff)

so what I made is to do these changes:
- enter (RETR) PREQUOTE state in no_transfer mode
- send the pre quote if any, once finished, do exatcly as exacting code

that way pre quote stuff works with CURLOPT_NOBODY (in this mode POSTQUOTE
is of no interest so let that not working)

--- C:\dev\sdk\curl-7.15.6-20060808\curl-7.15.6-20060808\lib\ftp.c
2006-07-26 04:00:42.000 +0200
+++ C:\dev\sdk\curl-7.15.4\lib\ftp.c 2006-08-08 11:38:57.000 +0200

@@ -1206,11 +1205,15 @@
   struct SessionHandle *data = conn->data;

   if(ftp->no_transfer || conn->bits.no_body) {
- /* then we're done with a "head"-like request, goto STOP */
- state(conn, FTP_STOP);

     /* doesn't transfer any data */
     ftp->no_transfer = TRUE;
+
+ /* then we're done with a "head"-like request, goto STOP */
+ /* still do PRE QUOTE jobs, to let the opportunity to the user to
+ profit from the CWD infrastructure */
+ state(conn, FTP_RETR_PREQUOTE);
+ result = ftp_state_quote (conn, TRUE, FTP_RETR_PREQUOTE);
   }
   else if(data->set.ftp_use_port) {
     /* We have chosen to use the PORT (or similar) command */
@@ -1497,8 +1500,12 @@
       result = ftp_state_cwd(conn);
       break;
     case FTP_RETR_PREQUOTE:
- NBFTPSENDF(conn, "SIZE %s", ftp->file);
- state(conn, FTP_RETR_SIZE);
+ if (ftp->no_transfer)
+ state(conn, FTP_STOP);
+ else {
+ NBFTPSENDF(conn, "SIZE %s", ftp->file);
+ state(conn, FTP_RETR_SIZE);
+ }
       break;
     case FTP_STOR_PREQUOTE:
       result = ftp_state_ul_setup(conn, FALSE);

Regards
Armel
Received on 2006-08-08