开发者

Discard response data from libcurl

开发者 https://www.devze.com 2023-02-09 19:19 出处:网络
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

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 开发者_Python百科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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号