vascop
vascop

Reputation: 5212

Discard response data from libcurl

Libcurl defaults to stdout when handling a server's response. We can override it with CURLOPT_WRITEFUNCTION and CURLOPT_WRITEDATA. From the manual I got that I could set the CURLOPT_WRITEFUNCTION to NULL and then pass a FILE * to CURLOPT_WRITEDATA. If I just want to not use it what would be the most efficient way to go about it?

Specifically, if you need to provide a FILE * to a function, but you want it to be discarded how would you go about it?

Also, as I'm writing this I realised that maybe I shouldn't pass NULL to CURLOPT_WRITEFUNCTION, and instead write a function which does nothing?

Upvotes: 1

Views: 439

Answers (1)

Piskvor left the building
Piskvor left the building

Reputation: 92772

Write to /dev/null or a similar black hole. Note that the existence and location of such special file(s) is OS dependent - Unixen have /dev/null, Windows has \Device\Null, etc.

Upvotes: 1

Related Questions