cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Re: How to avoid multiple CWD for each file download

From: Anders Havn <anders.havn_at_gmail.com>
Date: Thu, 20 Jun 2013 14:55:03 +0200

Hi again,

Can any of the commands CURLFTPMETHOD_NOCWD and CURLFTPMETHOD_SINGLECWD
cause the code to not work on some ftp servers? I tried using
CURLFTPMETHOD_NOCWD
on my own ftp server and it worked fine as long as the url didn't contain a
folder path, ex: "ftp://myftpserver.org/FirstFolder/". With this url it
couldn't list some subfolders in FirstFolder. Quite weird.
CURLFTPMETHOD_SINGLECWD still works with this url, so for now I will try
and use CURLFTPMETHOD_SINGLECWD unless this also can have some side effect
that I haven't run into yet?

Regarding the reuse of the curl handle I call this code when I connect to
the server:

curl_global_init(CURL_GLOBAL_DEFAULT);

curl = curl_easy_init();

and then this code for each operation performed on the server:

...

curl_easy_setopt([FTPHelper curlHandle], CURLOPT_URL, filePath);

curl_easy_setopt([FTPHelper curlHandle], CURLOPT_POSTQUOTE, headerList);

CURLcode result = curl_easy_perform([FTPHelper curlHandle]);
  curl_slist_free_all (headerList);

curl_easy_reset([FTPHelper curlHandle]);

...

I call curl_easy_reset because I have some other curl_easy_setopt calls that
isn't always used. And then I call the following code when disconnecting
from the server:

curl_easy_cleanup(curl);

curl_global_cleanup();

Is this the correct way to do it?

Thank you!

Best Regards,
Anders Havn

Subject: Re: How to avoid multiple CWD for each file download
> Message-ID: <alpine.DEB.2.00.1306192013390.18863_at_tvnag.unkk.fr>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Wed, 19 Jun 2013, Anders Havn wrote:
>
> > I'm downloading multiple files in a directory. The code run for each file
> > looks like this:
>
> ...
>
> > The log looks like this for each file. This means that the command CWD is
> > done three times for each file. This is properly not good for performace,
> > so how do I avoid this?
>
> Apart from Jeff's suggestion, don't close and re-create the easy handle all
> the time. Re-use it instead and you'll also gain a lot of performance!
>
> > Another problem is that after downloading about 50 files then it fails
> with
> > an error:
>
> > 2013-06-18 21:08:23> response reading failed 2013-06-18 21:08:23> Error
>
> That's what libcurl will say when it failed receiving data mid server
> response.
>
> --
>
> / daniel.haxx.se
>
>
>
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-06-20