Debug callback

The debug callback is set with CURLOPT_DEBUGFUNCTION:

  1. curl_easy_setopt(handle, CURLOPT_DEBUGFUNCTION, debug_callback);

The debug_callback function must match this prototype:

  1. int debug_callback(CURL *handle,
  2. curl_infotype type,
  3. char *data,
  4. size_t size,
  5. void *userdata);

This callback function replaces the default verbose output function in the
library and will get called for all debug and trace messages to aid
applications to understand what’s going on. The type argument explains what
sort of data that is provided: header, data or SSL data and in which direction
it flows.

A common use for this callback is to get a full trace of all data that libcurl
sends and receives. The data sent to this callback is always the unencrypted
version, even when, for example, HTTPS or other encrypted protocols are used.

This callback must return zero or cause the transfer to stop with an error
code.

The user pointer passed in to the callback in the userdata argument is set
with CURLOPT_DEBUGDATA:

  1. curl_easy_setopt(handle, CURLOPT_DEBUGDATA, custom_pointer);