curl-library
Why curl does CWD (was Re: Problem with subsequent persistant calls)
Date: Fri, 7 Dec 2001 13:46:22 +0100 (MET)
On Fri, 7 Dec 2001, Dimitris Sarris wrote:
> I use the the CURLOPT_QUOTE option in order to perform a 'CWD' command in
> order to list the files of a specific directory (not home directory).
>
> I perform these requests twice, using the persisting feature of libcurl
> (keep the same connection).
> The first listing is performed with no problem. However, the second
> listing is performed for the home directory and not for the directory I
> request in my 'CWD' command.
> As you can see at the output of my program (using VERBOSE mode), after
> my 'CWD' command, libcurl performs also a 'CWD' to the home directory.
> Is this the correct behavior?
[protocol dump cut off]
It is the correct behavior!
The reason is really quite simple: when you do repeated FTP requests, you
send a new path for each new request. Each request must thus start from the
same point. Therefore, on the first request curl checks which path it starts
in (using PWD) and records that directory. It then issues CWD to the proper
directory and transfers the file.
On a subsequent call, it first CWD back to the original directory and then
CWD away to the new dir given in the request.
Yes, this could/should be optimized to only one CWD in case the second
request is an absolute path.
Are you following?
-- Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/Received on 2001-12-07