cURL / Mailing Lists / curl-library / Single Mail

curl-library

FTP transfers default to ASCII mode

From: Angus March <angus_at_uducat.com>
Date: Tue, 14 Apr 2009 16:12:59 -0400

I'm having 2 problems where the implementation version of libcurl keeps
giving me these "URL using bad/illegal format or missing URL" errors
when there shouldn't be anything wrong w/the URLs. Another problem is
that when I can get these binary files to transfer, they go as ASCII,
and I don't know how to get them to transfer binary.
    The implementation machine is a 32-bit Suse Enterprise 10, which
uses libcurl 7.15.1 . That's a little older than what I have on the
development machine (7.19.0 on an AMD64 running Suse 11.1) and the
problem doesn't occur on that system.

    Here's some of my code:

        /* get a curl handle */
        curl = curl_easy_init();
            char error_buffer[CURL_ERROR_SIZE] = "";
            for(std::list<astring>::const_iterator iter =
dirprocessor.m_dir.begin(); iter != dirprocessor.m_dir.end(); ++iter) {
                FileProcessor fileprocessor;
                char *p;
                { /* specify target */
                    astring sThisURL = sFTPURL + *iter;
                    p = (char *)malloc(sThisURL.length() + 1);
                    strcpy(p, sThisURL);
                    g_pLog->LogLine((astring)"And this is the URL: " + p);
                    verify(curl_easy_setopt(curl, CURLOPT_URL, p) ==
CURLE_OK);
                }
                verify(curl_easy_setopt(curl, CURLOPT_ERRORBUFFER,
error_buffer) == CURLE_OK);
                verify(curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
write_callback) == CURLE_OK);
                verify(curl_easy_setopt(curl, CURLOPT_WRITEDATA,
&fileprocessor) == CURLE_OK);
                if (bHeaders)
                    verify(curl_easy_setopt(curl,
CURLOPT_HEADERFUNCTION, header_callback) == CURLE_OK);
                verify(curl_easy_setopt(curl, CURLOPT_USERPWD,
sUserPasswdCombo.c_str()) == CURLE_OK);

                /* Now run off and do what you've been told! */
                CURLcode res = curl_easy_perform(curl);
                if (res != 0) {
                    g_pLog->LogLine("Error transfering " + *iter);
                    g_pLog->LogLine((astring)"And the error is: " +
error_buffer + " and res was: " + LtoA(res));
                   char c[1000];
                   verify(curl_easy_getinfo(curl,
CURLINFO_EFFECTIVE_URL, c) == CURLE_OK);
                   g_pLog->LogLine((astring)"And the effective URL is: "
+ c);
                   g_pLog->LogLine((astring)"And here's p: " + p);
                }
                else fileprocessor.ProcessFile();
                free(p);
            }

All of the log messages indicate a proper URLs being inputted. Here's a
sample of such a URL:
ftp://ftp4.xxxxxx.com/SCI_Orders_20090413_20090414034001.txt. I don't
see anything bad, illegal or missing about that.
However, the effective URL comes out as gooble-degook, but p stays normal.
Received on 2009-04-14