cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: HTTP POST: howto get just the the response content?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 3 Apr 2011 00:09:02 +0200 (CEST)

On Sat, 2 Apr 2011, svante karlsson wrote:

> I'm new to libcurl so this might be obvious...
>
> If I do a HTTP get with a
> ....
> curl_easy_setopt(_curl, CURLOPT_WRITEFUNCTION, write_callback_std_stream);
> curl_easy_setopt(_curl, CURLOPT_WRITEDATA, ostream);
> ....
> then my callback "write_callback_std_stream" gets called with the
> content of the request.

No, it gets called with the content of the *response*. The request is what you
send to the server and that is not passed to the write callback.

> however using the same construct as above

> my callback gets called first with each response header then with the
> (my) desired content - while the headers are interesting is there a
> way of getting rid of those before the callback?

You should only get HTTP headers in the WRITEFUNCTION callback if you have
CURLOPT_HEADER set.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-04-03