cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 7 Dec 2001 14:20:18 +0100 (MET)

On Fri, 7 Dec 2001, Dimitris Sarris wrote:

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

Can you make this problem appear with the command line client?

I really can't see how the code can do wrong. Check the lib/ftp.c code, it is
just so easy to follow and clean. Allow me to paste it here:

-- snip -- (from around line 1490 in lib/ftp.c)

  /* Send any QUOTE strings? */
  if(data->set.quote) {
    if ((result = ftp_sendquote(conn, data->set.quote)) != CURLE_OK)
      return result;
  }

  /* This is a re-used connection. Since we change directory to where the
     transfer is taking place, we must now get back to the original dir
     where we ended up after login: */
  if (conn->bits.reuse) {
    if ((result = ftp_cwd(conn, ftp->entrypath)) != CURLE_OK)
      return result;
  }

  /* change directory first! */
  if(ftp->dir && ftp->dir[0]) {
    if ((result = ftp_cwd(conn, ftp->dir)) != CURLE_OK)
        return result;
  }

-- snip --

See? First it performs all the quoted commands, then it switches back to the
entry path from the first connection, then it changes to the transfer
directory.

How can that be wrong?

I tried a very simple command line doing both:

 $ curl ftp://localhost/tmp/ ftp://localhost/ -vi

and the other order:

 $ curl ftp://localhost/ ftp://localhost/tmp/ -vi

It just works.

The command you saw in your log ("CWD /home/users/jim/tmp") must have been
provided in the list of quote commands, it was not the one curl recorded as
"login path".

Or can you tell me where I'm wrong?

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2001-12-07