cURL / Mailing Lists / curl-library / Single Mail

curl-library

server not receiving POST data

From: Anna Gulaev <annagulaev_at_gmail.com>
Date: Wed, 30 Sep 2009 00:22:08 -0400

I used to be able to send data to a web server from a c++ program using
curl. Now all that's being received is thirty dashes followed by six
hexidecimal numbers, like this:

------------------------------07ac4edfb36c

The number is different each time. Doesn't matter what I send; this is
what's received.

Does anyone recognize this? It almost looks like the content separators on
the response. When I say "used to be able to..." I mean a couple days ago.
Not sure what I broke...

Here's the curl code:

    if ( CurlMultiHandle == NULL)
        CurlMultiHandle = curl_multi_init();

    if ( CurlMultiHandle)
    {
        CurlInfo *curl = (CurlInfo *) malloc( sizeof( CurlInfo));
        curl->EasyHandle = curl_easy_init();

        if ( curl->EasyHandle)
        {
            curl->formpost = NULL;
            curl->lastptr = NULL;

            serverLocData = serverLocData + "!\n" + AgentFirstName + " " +
AgentLastName + "\n!\n"; // exclamation ends data block

serverLocData = "This is a test";
            curl_formadd( &(curl->formpost), &(curl->lastptr),
                CURLFORM_COPYNAME, "CopyNameGoesHere",
                CURLFORM_COPYCONTENTS, serverLocData.c_str(),
                CURLFORM_END);
vAddChatHistory( "viewer", "sending:"+serverLocData);
vLogFile << "LOC_SERVER_SENDING >" << serverLocData << "<" << endl << flush;
            curl_formadd( &(curl->formpost), &(curl->lastptr),
                CURLFORM_COPYNAME, "submit",
                CURLFORM_COPYCONTENTS, "send",
                CURLFORM_END);

            curl->chunk.memory = NULL;
            curl->chunk.size = 0;

            curl_easy_setopt( curl->EasyHandle, CURLOPT_URL,
LOC_SERVER_UPDATE_URL);
            //curl_easy_setopt( curl->EasyHandle, CURLOPT_VERBOSE, 1);
            curl_easy_setopt( curl->EasyHandle, CURLOPT_POST, 1);
            curl_easy_setopt( curl->EasyHandle, CURLOPT_WRITEFUNCTION,
ReadWebpageCallback);
            curl_easy_setopt( curl->EasyHandle, CURLOPT_WRITEDATA, (void
*)&(curl->chunk));
            curl_easy_setopt( curl->EasyHandle, CURLOPT_USERAGENT,
"SLCustomViewer");
            curl_easy_setopt( curl->EasyHandle, CURLOPT_HTTPPOST,
curl->formpost);

            curl_multi_add_handle( CurlMultiHandle, curl->EasyHandle);

            CurlEasy.push_back( curl);

            // suck in as much data as is ready
            while( CURLM_CALL_MULTI_PERFORM == curl_multi_perform(
CurlMultiHandle, &CurlStillRunning)); //note semicolon

            if ( !CurlStillRunning)
                curlCleanup();
        }
        else
        {
            vLogFile << "LOC_SERVER_UPDATE_ERROR unable to send data to
server - unable to obtain curl handle" << endl << flush;
        }
    }
    else
    {
        vLogFile << "LOC_SERVER_UPDATE_ERROR unable to send data to server -
unable to obtain curl multihandle" << endl << flush;
    }

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-09-30