cURL / Mailing Lists / curl-library / Single Mail


Re: Send post data without recieving contents

From: Emil Romanus <>
Date: Mon, 20 Aug 2007 06:33:56 +0200

Hi again Brandon,

2007/8/20, Brandon <>:
> Sorry for a second email, but let me clarify:

I'm sure you don't have to be sorry for that. This list is open as long as
the discussion is libcurl related. :-)

I want the server to behave exactly the same as if I recieved the data, but
> since the data it sends back is large and useless, I would like a way to
> close the connection, or something similar.
> This guy apparently wants the same thing:
> Emil Romanus replied and said this "I'd suggest writing a callback
> function for the CURLOPT_WRITEFUNCTION. The callback function should simply
> return size*nmem and do nothing else."
Anyone know how to do this? Thanks so much, sorry for another email.

I suggest you forget that solution after what you wrote in this email! The
connection won't be closed when doing it that way, it will download the data
as usual but just discard it and not store it. So you will still waste the

I can't be of any more help since you need to close the connection. There
has however been some discussion regarding a somewhat related issue:
Scroll down to "How to close established by libcurl FTP connections". It
seems that this feature is not really implemented yet, but I'm sure it will

Oh wait, I just remembered! There is a way to cancel a transfer, a simple
CURLOPT_WRITEFUNCTION function that returns something else than size*nmem.

curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, &cancel_transfer_cb);
cancel_transfer_cb(char *data, size_t size, size_t nmem, void *dsa)
    return !(size*nmem);

This will cancel the transfer upon the first read of any data returned from
the server. This is probably a VERY BAD solution. Your curl_easy_perform()
will also probably return something else than CURLE_OK, but your POST sure
was sent.

Someone more experienced can probably provide a better solution.
Received on 2007-08-20