cURL / Mailing Lists / curl-library / Single Mail

curl-library

Response code 0 from curl_easy_perform

From: Michael Leong <michael_at_voltage.com>
Date: Fri, 24 Jul 2009 10:10:14 -0700

Hi all,

I have this piece of code in which I use curl to do some networking:

    /* Now we are ready to make the network connection. After we receive
     * the response we should see what kind of response it is
     */
    cStatus = curl_easy_perform (curl);
    if (cStatus == CURLE_RECV_ERROR)
    {
      cStatus = curl_easy_perform(curl);
    }
    if (cStatus != CURLE_OK)
      break;

    cStatus = curl_easy_getinfo (curl, CURLINFO_HTTP_CODE, responseCode);
    printf("\nResponse Code, curlDoHTTP #1: %d\n", *responseCode);
    if (cStatus != CURLE_OK)
      break;

It has worked in the past, and I'm porting it to a new system. In the past, we expect *responseCode (responseCode is an int*) to get back 200, 404, or something of the like. However, now it's always returning 0, no matter what the outcome is. Here's a dump from a sample program illustrating this problem. Any ideas as to why the response code is always 0, or what might be going wrong?

<snip... connection attempt here>

< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: text/xml
< Content-Length: 1535
< Date: Fri, 24 Jul 2009 16:31:29 GMT
< Connection: close
<
* Closing connection #0

Response Code, curlDoHTTP #1: 0

<snip... connection attempt here>

< HTTP/1.1 404 Not Found
< Server: Apache-Coyote/1.1
< Date: Fri, 24 Jul 2009 16:31:29 GMT
< Connection: close
<
* Closing connection #0

Response Code, curlDoHTTP #1: 0

Thanks.
-Michael
Received on 2009-07-24