curl-library
simple HTTP POST help needed
Date: Thu, 22 Jan 2009 09:48:25 -0500
Hello,
I made a small program to POST a message to a HTTP Server. What I am wondering, is how do I get the acknowledgement message form the HTTP server with libcurl? I think I probably need to use a callback, but I read the docs and I am confused. Can anyone help me here? Here is the code to my program so far:
#include <CurlHandle.h>
using namespace std;
CCurlHandle::CCurlHandle(string url)
{
curl_global_init(CURL_GLOBAL_ALL);
_easyHandle = curl_easy_init();
#ifdef DEBUG
curl_easy_setopt(_easyHandle, CURLOPT_VERBOSE, 1);
curl_easy_setopt(_easyHandle, CURLOPT_HEADER, 1);
#endif
_url = url;
int errorCode = curl_easy_setopt(_easyHandle, CURLOPT_URL, _url.c_str());
}
CCurlHandle::~CCurlHandle()
{
curl_easy_cleanup(_easyHandle);
}
void CCurlHandle::SendDatatoHTTPServer(string data)
{
// send data to _url
curl_easy_setopt(_easyHandle, CURLOPT_POSTFIELDS, data.c_str());
curl_easy_setopt(_easyHandle, CURLOPT_URL, _url);
curl_easy_perform(_easyHandle);
}
Received on 2009-01-22