cURL / Mailing Lists / curl-library / Single Mail


Libcurl POST XML file URGENT help

From: Addanki Venkat <>
Date: Tue, 12 Aug 2008 15:28:49 -0400

I am new to libcurl and I am trying to POST XML file (size up to 500 bytes).
I am giving the code below.


When I look at ethereal trace I don't see any data only header will be
there, I tried with sample string as length 500 considered as big. Still it
has same problem. I am not able to send even single character as data along
with HTTP1.1 POST.


I stuck with this problem and no clue since yesterday evening. I really
appreciate any one can give quick solution.


Thanks in advance,


Here is code chunk,


bool CControlStream::OpenCURLSession()



                m_pCURL = curl_easy_init();


                if (m_pCURL)


                                // HTTP Authentication

                                curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH,

                                curl_easy_setopt(m_pCURL, CURLOPT_USERPWD,


                                // Set the URL that is about to receive our
POST. This URL can

                                // just as well be a https:// URL if that is
what should receive the data.

                                curl_easy_setopt(m_pCURL, CURLOPT_URL,


                                return true;



                                return false;



void CControlStream::CloseCURLSession()


                if (m_pCURL)










                CURLcode res;

                ostringstream xrStream;

                m_pXmlRes.memory = NULL;

                m_pXmlRes.size = 0;


                LPDCS_ConferenceData pConfData


                char sTmp[15];

                char test[30];

                char curlError[CURL_ERROR_SIZE+1];


                CString sConfName = ((pConfData->generic).sResource).szName;


                m_MGCXmlParser.fnConfStartXmlMsg(sConfName, sTmp, xrStream);


                strcpy(test, "My Test libcurl Program");


                struct curl_slist *headers=NULL;

                headers = curl_slist_append(headers, "Content-Type:


                curl_easy_setopt(m_pCURL, CURLOPT_POST, 1);


                std::string strDoc = "xmldoc=" + xrStream.str();


                std::cout << strDoc.c_str() << std::endl;

                //curl_easy_setopt(m_pCURL, CURLOPT_POSTFIELDS, (char

                curl_easy_setopt(m_pCURL, CURLOPT_POSTFIELDS, (char *)test);


                /* we pass our 'chunk' struct to the callback function */

                curl_easy_setopt(m_pCURL, CURLOPT_WRITEDATA, (void


                curl_easy_setopt(m_pCURL, CURLOPT_HEADER, 0 );


                curl_easy_setopt(m_pCURL, CURLOPT_WRITEFUNCTION,


                curl_easy_setopt(m_pCURL, CURLOPT_ERRORBUFFER, curlError);

                curl_easy_setopt(m_pCURL, CURLOPT_NOPROGRESS, 1);


                /* pass our list of custom made headers */

                curl_easy_setopt(m_pCURL, CURLOPT_HTTPHEADER, headers);


                std::cout << strDoc.size() << std::endl;

                /* set the size of the postfields data */

                //curl_easy_setopt(m_pCURL, CURLOPT_POSTFIELDSIZE,



                /* Perform the request, res will get the return code */

                res = curl_easy_perform(m_pCURL);


                curl_slist_free_all(headers); /* free the header list */









                return true;
Received on 2008-08-12