36 else return size*nmemb;
39 static size_t curl_ev_on_body(
char *buffer,
size_t size,
size_t nmemb,
void *userdata)
43 else return size*nmemb;
50 (cc = curl_easy_setopt(handle, CURLOPT_HEADERDATA, data)) ||
51 (cc = curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION,
curl_ev_on_body)) ||
52 (cc = curl_easy_setopt(handle, CURLOPT_WRITEDATA, data)))
62 if (!(handle->
handle = curl_easy_init()))
66 curl_easy_cleanup(handle->
handle);
128 if ((cc = curl_easy_setopt(handle->
handle, CURLOPT_CUSTOMREQUEST, request)))
149 if ( (cc = curl_easy_setopt(handle->
handle, CURLOPT_POSTFIELDSIZE, len)) ||
150 (cc = curl_easy_setopt(handle->
handle, CURLOPT_COPYPOSTFIELDS, data)))
159 if ((cc = curl_easy_setopt(handle->
handle, CURLOPT_URL, url)))
168 if ((cc = curl_easy_setopt(handle->
handle, CURLOPT_VERBOSE,
bool)))
182 struct curl_slist *headers = curl_slist_append(handle->
headers, header);
185 if ((cc = curl_easy_setopt(handle->
handle, CURLOPT_HTTPHEADER, handle->
headers)))
void(* hpd_curl_ev_free_f)(void *userdata)
hpd_error_t hpd_curl_ev_init(hpd_curl_ev_handle_t **handle, const hpd_module_t *context)
#define HPD_LOG_RETURN(CONTEXT, E, FMT,...)
hpd_error_t hpd_curl_ev_add_header(hpd_curl_ev_handle_t *handle, const char *header)
HPD_E_UNKNOWN: handle may be in an inconsistent state, and should not be added before a call to this ...
const hpd_module_t * context
void(* hpd_curl_ev_done_f)(void *userdata, int curl_code)
hpd_curl_ev_done_f on_done
size_t(* hpd_curl_ev_f)(char *buffer, size_t size, size_t nmemb, void *userdata)
hpd_curl_ev_free_f on_free
struct curl_slist * headers
#define HPD_CALLOC(PTR, NUM, CAST)
Allocates and zeros a structure.
hpd_error_t hpd_curl_ev_set_postfields(hpd_curl_ev_handle_t *handle, const void *data, size_t len)
HPD_E_UNKNOWN: handle may be in an inconsistent state, and should not be added before a call to this ...
enum hpd_error hpd_error_t
#define HPD_LOG_RETURN_E_ALLOC(CONTEXT)
hpd_error_t hpd_curl_ev_set_header_callback(hpd_curl_ev_handle_t *handle, hpd_curl_ev_f on_header)
static hpd_error_t curl_ev_init_curl_handle(CURL *handle, const hpd_module_t *context, void *data)
hpd_error_t hpd_curl_ev_set_verbose(hpd_curl_ev_handle_t *handle, long int bool)
#define HPD_LOG_RETURN_E_NULL(CONTEXT)
hpd_error_t hpd_curl_ev_set_body_callback(hpd_curl_ev_handle_t *handle, hpd_curl_ev_f on_body)
hpd_error_t hpd_curl_ev_set_url(hpd_curl_ev_handle_t *handle, const char *url)
static size_t curl_ev_on_body(char *buffer, size_t size, size_t nmemb, void *userdata)
hpd_error_t hpd_curl_ev_set_custom_request(hpd_curl_ev_handle_t *handle, const char *request)
static hpd_error_t curl_ev_create_curl_handle(hpd_curl_ev_handle_t *handle)
hpd_error_t hpd_curl_ev_set_done_callback(hpd_curl_ev_handle_t *handle, hpd_curl_ev_done_f on_done)
hpd_error_t hpd_curl_ev_cleanup(hpd_curl_ev_handle_t *handle)
static size_t curl_ev_on_header(char *buffer, size_t size, size_t nmemb, void *userdata)
hpd_error_t hpd_curl_ev_set_data(hpd_curl_ev_handle_t *handle, void *data, hpd_curl_ev_free_f on_free)