cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Why curl does CWD (was Re: Problem with subsequent persistant calls)

From: Dimitris Sarris <dsar_at_intracom.gr>
Date: Fri, 07 Dec 2001 14:58:56 +0200

Daniel Stenberg wrote:

> 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.

Correct.

>
> On a subsequent call, it first CWD back to the original directory and then
> CWD away to the new dir given in the request.

What you express here is the correct behavior. However, curl first CWD
away to
the new dir given in my request, (CWD /home/users/jim/tmp) and then
CWD back to the original directory (CWD /home/users/jim). (see the
protocol
dump)

>
> Yes, this could/should be optimized to only one CWD in case the second
> request is an absolute path.
>
> Are you following?

Of course, you can optimize it, but even if I give a relative path, it
first
tries to CWD to the directory I give my request (of course it fails).
Thus, I believe that the bug must be solved first, and then optimize the
code.
:-)

Thanks,
Dimitris
Received on 2001-12-07