cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Handling FTP servers that indicate backslash as CWD

From: John Coffey <johnco3_at_gmail.com>
Date: Wed, 11 Feb 2015 08:21:55 -0500

Dan, I already use this option, however it does not appear to prevent the
automatic CWD when I first login. That option appears to only be used for
traversing directories when already logged in.

My default curl options are set as follows:

. . .
    auto res = curl_easy_setopt(pCurl, CURLOPT_FTP_USE_EPSV, 0L);
    res = curl_easy_setopt(pCurl, CURLOPT_FTP_USE_EPRT, 0L);
    res = curl_easy_setopt(pCurl, CURLOPT_NOSIGNAL, 1L);

    // do not perform CWD when traversing the pseudo directories
    res = curl_easy_setopt(pCurl, CURLOPT_FTP_FILEMETHOD,
CURLFTPMETHOD_NOCWD);
    res = curl_easy_setopt(pCurl, CURLOPT_CONNECTTIMEOUT,
getConnectTimeoutSecs());

    if (!isPASVMode()) {
        res = curl_easy_setopt(pCurl, CURLOPT_FTPPORT, "-");
    }
    // used to capture header traffic
    if (mHeaderCallback) {
        res = curl_easy_setopt(pCurl, CURLOPT_WRITEHEADER, mpHeaderStream);
        res = curl_easy_setopt(pCurl, CURLOPT_HEADERFUNCTION,
mHeaderCallback);
    }
    // for FTP GET operations
    if (mWriteDataCallback) {
        res = curl_easy_setopt(pCurl, CURLOPT_WRITEDATA, &mScratchBuffer);
        res = curl_easy_setopt(pCurl, CURLOPT_WRITEFUNCTION,
mWriteDataCallback);
    }
    // for FTP PUT operations
    if (mReadFileCallback) {
        res = curl_easy_setopt(pCurl, CURLOPT_READFUNCTION,
mReadFileCallback);
    }

    // progress callback used to track upload progress only
    if (mProgressCallback) {
        res = curl_easy_setopt(pCurl, CURLOPT_XFERINFOFUNCTION,
mProgressCallback);
        res = curl_easy_setopt(pCurl, CURLOPT_XFERINFODATA, nullptr);
        res = curl_easy_setopt(pCurl, CURLOPT_NOPROGRESS, 0L);
    }

    // verbose logging
    if (mDebuggingCallback) {
        res = curl_easy_setopt(pCurl, CURLOPT_VERBOSE, 1L);
        res = curl_easy_setopt(pCurl, CURLOPT_DEBUGFUNCTION,
mDebuggingCallback);
        res = curl_easy_setopt(pCurl, CURLOPT_DEBUGDATA, nullptr);
    } else {
        res = curl_easy_setopt(pCurl, CURLOPT_VERBOSE, 0L);
        res = curl_easy_setopt(pCurl, CURLOPT_DEBUGDATA, nullptr);
    }

    // disable Nagle algorithm - to fix slowdown in bulk transfers
    // with large data files @JC not necessary
    //res = curl_easy_setopt(pCurl, CURLOPT_TCP_NODELAY, 1L);
    if (mSocketOptionCallback) {
        res = curl_easy_setopt(pCurl, CURLOPT_SOCKOPTDATA, nullptr);
        res = curl_easy_setopt(pCurl, CURLOPT_SOCKOPTFUNCTION,
mSocketOptionCallback);
    }
. . .

John

---------- Forwarded message ----------
From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, Feb 11, 2015 at 3:14 AM
Subject: Re: Handling FTP servers that indicate backslash as CWD
To: curl-library_at_cool.haxx.se

On Wed, Feb 11, 2015 at 12:38:00AM -0500, John Coffey wrote:
> Does anyone know of a way to avoid the automatic CWD command in libCurl,
 as I
> am connecting to an FTP server that indicates "\" is current working
> directory. I am only uploading files to this server, so I do not need to
know
> the current working directory.

The CURLOPT_FTP_FILEMETHOD option has a CURLFTPMETHOD_NOCWD that does this.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-02-11