I am new to libcurl and I am trying to POST XML file (size up to 500 bytes).
When I look at ethereal trace I don't see any data only header will be
I stuck with this problem and no clue since yesterday evening. I really
Thanks in advance,
Here is code chunk,
bool CControlStream::OpenCURLSession()
{
curl_global_init(CURL_GLOBAL_ALL);
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
// just as well be a https:// URL if that is
curl_easy_setopt(m_pCURL, CURLOPT_URL,
return true;
}
else
return false;
}
void CControlStream::CloseCURLSession()
{
if (m_pCURL)
{
curl_easy_cleanup(m_pCURL);
}
}
OpenCURLSession();
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];
sprintf(sTmp,"%d",(pConfData->generic).ConferenceID.rid);
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 */
if(m_pXmlRes.size)
{
ExtractTokens(m_pXmlRes);
free(m_pXmlRes.memory);
}
CloseCURLSession();
return true;
|
|