cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLOPT_WRITEFUNCTION returning missing DATA

From: Nash Kabbara <nash_at_lconn.com>
Date: Tue, 12 Mar 2002 16:02:04 -0800

Hi there,
When I run , CURLOPT_WRITEFUNCTION, option not all data is being passed to "char file[]". I am supposed to get an XML string ,but I only get part of it. Now when I DO NOT set the CURLOPT_WRITEFUNCTION option curl outputs the complete XML string to stdout. I need to find out why calling CURLOPT_WRITEFUNCTION is eating part of my returned data. Thanks in advance for any help. All the relevant info i below.

            /* Curl Stuff */
            CurlPtr = curl_easy_init();
            curl_easy_setopt (CurlPtr, CURLOPT_URL, "https://secure.blalalacom/blablou.asp");

             curl_easy_setopt (CurlPtr, CURLOPT_POST, 1);

            curl_easy_setopt (CurlPtr, CURLOPT_POSTFIELDS, Temp2.c_str());

            curl_easy_setopt (CurlPtr, CURLOPT_POSTFIELDSIZE, 0);

            curl_easy_setopt (CurlPtr, CURLOPT_TIMEOUT, 360);

            curl_easy_setopt (CurlPtr, CURLOPT_HEADER, 0);

            curl_easy_setopt (CurlPtr, CURLOPT_SSLVERSION, 3);

            curl_easy_setopt (CurlPtr, CURLOPT_WRITEFUNCTION, ReadXML);

            curl_easy_perform(CurlPtr);

The func called by , CURLOPT_WRITEFUNCTION, is:
size_t ReadXML(char file[], size_t size, size_t nmemb, void *stream)
      {
      string XMLData; // string obj
      const int MAX = 2048;
      int actual;

      actual = size*nmemb ; // number of chars * bytes

      XMLData.insert(0,file); // copies what 'file' points to into the obj string

      cout << actual << " ________\n" << XMLData.c_str() << "\n---------------" << endl;

     return 0;
     }

The corrupt result when invoking my function:
<?xml version="1.0"?>
<ncresponse
orderID="12319"
PAYID="83096"
PAYIDSUB="1"
NCSTATUS="5"
NCERROR="50001116"
NCERRORPLUS="unknown o

The complete result when outputting to stdout:
<?xml version="1.0"?>
<ncresponse
orderID="123123123b"
PAYID="82931"
PAYIDSUB="1"
NCSTATUS="5"
NCERROR="50001116"
NCERRORPLUS="unknown origip/209.163.136.188//216.92.131.246;209.163.136.101/"
ACCEPTANCE=""
STATUS="0">
</ncresponse>

Again thanks for any help.
Received on 2002-03-12