HTTP client libcurl implementation file. More...
Go to the source code of this file.
Data Structures | |
struct | libcurl_payload_t |
Macros | |
#define | CARRIAGE_RETURN '\r' |
#define | LINE_FEED '\n' |
#define | DOMAIN_SEPERATOR '\\' |
#define | SUPPORTED_CIPHERS_LIST |
Functions | |
static CURLcode | _ssl_context_callback (CURL *curl, void *ssl_context, void *certificate) |
static mcl_size_t | _response_payload_callback (void *received_data, mcl_size_t size, mcl_size_t count, void *response_payload) |
static mcl_size_t | _response_header_callback (void *received_data, mcl_size_t size, mcl_size_t count, void *response_header) |
static mcl_size_t | _request_payload_callback_for_put (char *buffer, mcl_size_t size, mcl_size_t count, void *http_request) |
static mcl_bool_t | _is_empty_line (char *line) |
static struct curl_slist * | _set_request_options (CURL *curl, http_request_t *http_request, http_client_send_callback_info_t *callback_info) |
static int | _curl_debug_callback (CURL *curl, curl_infotype info_type, char *data, mcl_size_t size, void *debug_data) |
static E_MCL_ERROR_CODE | _convert_to_mcl_error_code (CURLcode curl_code) |
E_MCL_ERROR_CODE | http_client_initialize (configuration_t *configuration, http_client_t **http_client) |
HTTP Client initializer. More... | |
E_MCL_ERROR_CODE | http_client_send (http_client_t *http_client, http_request_t *http_request, http_client_send_callback_info_t *callback_info, http_response_t **http_response) |
Send/Receive function. More... | |
mcl_size_t | http_client_get_callback_termination_code () |
To get the implementation specific code for returning from callback function in order to terminate the send operation. More... | |
void | http_client_destroy (http_client_t **http_client) |
To destroy the HTTP Client Handler. More... | |
Variables | |
static mcl_bool_t | curl_global_initialized = MCL_FALSE |
HTTP client libcurl implementation file.
Definition in file http_client_libcurl.c.
#define CARRIAGE_RETURN '\r' |
Definition at line 26 of file http_client_libcurl.c.
Referenced by _is_empty_line().
#define DOMAIN_SEPERATOR '\\' |
Definition at line 28 of file http_client_libcurl.c.
Referenced by http_client_initialize().
#define LINE_FEED '\n' |
Definition at line 27 of file http_client_libcurl.c.
Referenced by _is_empty_line().
#define SUPPORTED_CIPHERS_LIST |
Definition at line 30 of file http_client_libcurl.c.
Referenced by http_client_initialize().
|
static |
Definition at line 560 of file http_client_libcurl.c.
References DEBUG_ENTRY, DEBUG_LEAVE, MCL_COULD_NOT_CONNECT, MCL_COULD_NOT_RESOLVE_HOST, MCL_COULD_NOT_RESOLVE_PROXY, MCL_FAIL, MCL_IMPROPER_CERTIFICATE, MCL_NETWORK_RECEIVE_FAIL, MCL_NETWORK_SEND_FAIL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_REQUEST_TIMEOUT, MCL_SERVER_CERTIFICATE_NOT_VERIFIED, and MCL_SSL_HANDSHAKE_FAIL.
Referenced by http_client_send().
|
static |
Referenced by _set_request_options(), and http_client_initialize().
|
static |
Definition at line 416 of file http_client_libcurl.c.
References CARRIAGE_RETURN, DEBUG_ENTRY, DEBUG_LEAVE, LINE_FEED, MCL_FALSE, and MCL_TRUE.
Referenced by _response_header_callback().
|
static |
Definition at line 390 of file http_client_libcurl.c.
References DEBUG_ENTRY, DEBUG_LEAVE, MCL_DEBUG, http_request_t::payload, http_request_t::payload_offset, http_request_t::payload_size, and string_util_memcpy().
Referenced by _set_request_options().
|
static |
Definition at line 352 of file http_client_libcurl.c.
References _is_empty_line(), DEBUG_ENTRY, DEBUG_LEAVE, MCL_ERROR, MCL_NULL, MCL_OK, MCL_TRUE, string_array_add(), string_destroy(), and string_initialize_new().
Referenced by http_client_initialize().
|
static |
Definition at line 322 of file http_client_libcurl.c.
References ASSERT_CODE_MESSAGE, libcurl_payload_t::data, DEBUG_ENTRY, DEBUG_LEAVE, MCL_MALLOC, MCL_NULL, MCL_RESIZE, libcurl_payload_t::size, and string_util_memcpy().
Referenced by http_client_initialize().
|
static |
Definition at line 427 of file http_client_libcurl.c.
References _curl_debug_callback(), _request_payload_callback_for_put(), string_t::buffer, libcurl_payload_t::data, DEBUG_ENTRY, DEBUG_LEAVE, http_request_t::header, http_header_names, HTTP_HEADER_TRANSFER_ENCODING_CHUNKED, string_array_t::index, MCL_DEBUG, MCL_DEBUG_MEMORY, MCL_ERROR_RETURN, MCL_HTTP_GET, MCL_HTTP_POST, MCL_HTTP_PUT, MCL_NULL, http_request_t::method, http_request_t::payload, http_request_t::payload_offset, http_request_t::payload_size, http_client_send_callback_info_t::read_callback, libcurl_payload_t::size, string_array_get(), http_request_t::uri, and http_client_send_callback_info_t::user_context.
Referenced by http_client_send().
|
static |
Definition at line 250 of file http_client_libcurl.c.
References ASSERT_CODE_MESSAGE, string_t::buffer, DEBUG_ENTRY, DEBUG_LEAVE, string_t::length, MCL_ERROR_RETURN, MCL_INFO, and MCL_NULL.
Referenced by http_client_initialize().
void http_client_destroy | ( | http_client_t ** | http_client | ) |
To destroy the HTTP Client Handler.
Will release the resources of HTTP Request. After destroy operation, handler shouldn't be used.
[in] | http_client | HTTP Client Handler. |
Definition at line 230 of file http_client_libcurl.c.
References DEBUG_ENTRY, DEBUG_LEAVE, MCL_DEBUG, MCL_FREE, and MCL_NULL.
Referenced by http_processor_destroy().
mcl_size_t http_client_get_callback_termination_code | ( | ) |
To get the implementation specific code for returning from callback function in order to terminate the send operation.
Definition at line 220 of file http_client_libcurl.c.
References DEBUG_ENTRY, and DEBUG_LEAVE.
Referenced by _get_payload_from_file().
E_MCL_ERROR_CODE http_client_initialize | ( | configuration_t * | configuration, |
http_client_t ** | http_client | ||
) |
HTTP Client initializer.
Initializes the underlying implementation (like libcurl) with the given configuration data.
[in] | configuration | The configuration data. This is the same configuration data given to configuration_t when initializing it. |
[out] | http_client | Handle for the http client initialized. |
Definition at line 52 of file http_client_libcurl.c.
References _curl_debug_callback(), _response_header_callback(), _response_payload_callback(), _ssl_context_callback(), ASSERT_CODE_MESSAGE, string_t::buffer, curl_global_initialized, DEBUG_ENTRY, DEBUG_LEAVE, DOMAIN_SEPERATOR, configuration_t::http_request_timeout, string_t::length, MCL_DEBUG, MCL_FALSE, MCL_INITIALIZATION_FAIL, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_TRUE, memory_calloc(), memory_free(), memory_malloc(), memory_realloc(), configuration_t::mindsphere_certificate, configuration_t::mindsphere_port, configuration_t::proxy_domain, configuration_t::proxy_hostname, configuration_t::proxy_password, configuration_t::proxy_port, configuration_t::proxy_type, configuration_t::proxy_username, SSL_CERTIFICATE_TYPE_PEM, string_destroy(), string_initialize_new(), string_util_snprintf(), string_util_strdup(), and SUPPORTED_CIPHERS_LIST.
Referenced by http_processor_initialize().
E_MCL_ERROR_CODE http_client_send | ( | http_client_t * | http_client, |
http_request_t * | http_request, | ||
http_client_send_callback_info_t * | callback_info, | ||
http_response_t ** | http_response | ||
) |
Send/Receive function.
Using underlying implementation, it sends the given data to the pre-configured destination and returns the response. This function is blocking until response received or timeout occurred.
[in] | http_client | HTTP Client Handler. |
[in] | http_request | HTTP Request object. |
[in] | callback_info | Struct holding callback information. Refer to its definition http_client_send_callback_info_t . |
[out] | http_response | HTTP Response object. |
Definition at line 156 of file http_client_libcurl.c.
References _convert_to_mcl_error_code(), _set_request_options(), ASSERT_STATEMENT_CODE_MESSAGE, http_client_t::curl, libcurl_payload_t::data, DEBUG_ENTRY, DEBUG_LEAVE, http_response_initialize(), MCL_ERROR_RETURN, MCL_FREE, MCL_INFO, MCL_NEW, MCL_NULL, MCL_OK, libcurl_payload_t::size, string_array_destroy(), and string_array_initialize().
Referenced by http_processor_exchange(), http_processor_get_access_token(), http_processor_register(), and http_processor_stream().
|
static |
Definition at line 41 of file http_client_libcurl.c.
Referenced by http_client_initialize().