cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_easy_perform with CURLOPT_NOBODY = 1 returns 0 when ftp file does not exist.

From: Wei Weng <wweng_at_acedsl.com>
Date: Mon, 29 Sep 2008 12:06:54 -0400

Carlos Alloatti wrote:
> On Sun, Sep 28, 2008 at 10:47 PM, Dan Fandrich <dan_at_coneharvesters.com> wrote:
>
> Dan,
>
> thank you for your response and for taking some time to check out my problem.
>
> Please excuse my ignorance, but I don't see the relation between your
> test conditions and the problem I described. I had to check out what
> the -l option means, since I have only used the libcurl library, and
> this is what I could find:
>
>
> I may be wrong of course, and for shure there must be something that
> I' am not seeing, after all, I have been playing with the libcurl
> library for about week only.
>

I made a small program,

#include <stdio.h>

#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>

int main(int argc, char **argv)
{
        CURL *curl;
        CURLcode res;

        curl_global_init(CURL_GLOBAL_DEFAULT);

        curl = curl_easy_init();
        if (curl)
        {
                curl_easy_setopt(curl, CURLOPT_NOBODY, 0);
                curl_easy_setopt(curl, CURLOPT_URL,
                        "ftp://ftp.mozilla.org/invalid-file");

                res = curl_easy_perform(curl);

                curl_easy_cleanup(curl);

                fprintf(stderr, "curl told us %d\n", res);
        }

        curl = curl_easy_init();
        if (curl)
        {
                curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
                curl_easy_setopt(curl, CURLOPT_URL,
                        "ftp://ftp.mozilla.org/invalid-file");
                /* curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); */

                res = curl_easy_perform(curl);

                curl_easy_cleanup(curl);

                fprintf(stderr, "curl told us %d\n", res);
        }

        curl_global_cleanup();

        return 0;
}

And the output is

[ 00:02:38 ] wweng /home/wweng $ ./a.out
curl told us 19
Accept-ranges: bytes
curl told us 0

CURLOPT_NOBODY changed the response code.

Thanks
Wei
Received on 2008-09-29