cURL / Mailing Lists / curl-users / Single Mail

curl-users

echo to function curl_easy_perform

From: Joe Baldwin <joe.baldwin19_at_gmail.com>
Date: Tue, 9 Dec 2008 16:41:35 -0500

Hi,

I took an example from the libcurl package download that I modified to make
some tests.
The original program was "post-callback.c". My modified version is:

 int main(void)
{
  CURL *curl;
  CURLcode res;
  struct WriteThis pooh;
  pooh.readptr = data;
  pooh.sizeleft = strlen(data);
  curl = curl_easy_init();
  if (curl) {
    /* First set the URL that is about to receive our POST. */
    curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.1.200/bgs.exe");
 /* Now specify the POST data */
 curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 1);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "DATA=0001");
    /* Now specify we want to POST data */
    curl_easy_setopt(curl, CURLOPT_POST, 1);
    /* we want to use our own read function */
    curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
    /* pointer to pass to our read function */
    curl_easy_setopt(curl, CURLOPT_READDATA, &pooh);
    /* get verbose debug output please */
    //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, pooh.sizeleft);
 /* Perform the request, res will get the return code */
    res = curl_easy_perform(curl);
 printf ("res=%d\n",res);
    /* always cleanup */
    curl_easy_cleanup(curl);
  }
  return 0;
}
When the curl_easy_perform function is executed, the data received from the
HTTP server is displayed in my cmd window.
I also receive the content of the answer in pooh variable. How can I avoid
the echo of the answer returned by HTTP server ?

Thanks,

Joe

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2008-12-09