mcl_http_client.h File Reference

HTTP client interface header file. More...

Include dependency graph for mcl_http_client.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mcl_http_client_configuration_t
 

Functions

MCL_CORE_EXPORT mcl_error_t mcl_http_client_initialize (mcl_http_client_configuration_t *configuration, mcl_http_client_t **http_client)
 
MCL_CORE_EXPORT mcl_error_t mcl_http_client_add_certificate (mcl_http_client_t *http_client, const char *certificate, mcl_bool_t is_file)
 
MCL_CORE_EXPORT mcl_error_t mcl_http_client_send (mcl_http_client_t *http_client, mcl_http_request_t *http_request, mcl_http_response_t **http_response)
 
MCL_CORE_EXPORT void mcl_http_client_destroy (mcl_http_client_t **http_client)
 

Detailed Description

HTTP client interface header file.

MCL presents an HTTP client interface for which different implementations can be provided. This module is used internally by other MCL modules though it can also be used by the agent as a generic HTTP client. Agent can initialize an HTTP client with mcl_http_client_initialize function based on the configuration in mcl_http_client_configuration_t data structure. Following initialization, agent can send HTTP requests (mcl_http_request_t) and receive HTTP responses (mcl_http_response_t) using mcl_http_client_send function. Agent is expected to destroy the HTTP client when it is no longer needed using mcl_http_client_destroy function.

Definition in file mcl_http_client.h.

Function Documentation

MCL_CORE_EXPORT mcl_error_t mcl_http_client_add_certificate ( mcl_http_client_t http_client,
const char *  certificate,
mcl_bool_t  is_file 
)

This function adds server certificate to certificate list of http client. The certificate list is used by the http client to identify server(s).

Parameters
[in]http_clientHTTP client handle.
[in]certificateCertificate.
[in]is_fileMCL_TRUE if certificate is given as file.
Returns

Definition at line 109 of file http_client_basic.c.

References _certificate_list_destroy_callback(), _ssl_context_callback(), mcl_http_client_t::certificate_chain, mcl_http_client_t::certificates, mcl_certificate_t::content, mcl_list_t::count, mcl_http_client_t::curl, mcl_certificate_t::is_file, MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, mcl_list_add(), MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, mcl_tls_ca_chain_add_certificate(), MCL_TRUE, and string_util_strdup().

Referenced by mcl_http_client_initialize().

Here is the call graph for this function:

Here is the caller graph for this function:

MCL_CORE_EXPORT void mcl_http_client_destroy ( mcl_http_client_t **  http_client)

This function will release the resources of HTTP client handle.

Parameters
[in]http_clientHTTP client handle.

Definition at line 239 of file http_client_basic.c.

References _certificate_list_destroy_callback(), MCL_DEBUG, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, mcl_list_destroy_with_content(), MCL_NULL, and mcl_tls_ca_chain_destroy().

Referenced by core_processor_destroy(), and mcl_http_client_initialize().

Here is the call graph for this function:

Here is the caller graph for this function:

MCL_CORE_EXPORT mcl_error_t mcl_http_client_initialize ( mcl_http_client_configuration_t configuration,
mcl_http_client_t **  http_client 
)

This function initializes the underlying implementation (like libcurl) with the given configuration data.

Parameters
[in]configurationPointer to preinitialized mcl_http_client_configuration_t struct.
[out]http_clientHandle for the http client initialized.
Returns

Definition at line 58 of file http_client_basic.c.

References _response_header_callback(), _response_payload_callback(), mcl_http_client_configuration_t::certificate, mcl_http_client_configuration_t::certificate_is_file, curl_global_initialized, DOMAIN_SEPERATOR, mcl_http_client_configuration_t::http_request_timeout, MCL_ASSERT_CODE_MESSAGE, MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, MCL_FAIL, MCL_FALSE, MCL_FUNCTION_LEAVE_LABEL, mcl_http_client_add_certificate(), mcl_http_client_destroy(), MCL_INVALID_PARAMETER, mcl_list_initialize(), MCL_MALLOC, mcl_memory_calloc(), mcl_memory_free(), mcl_memory_malloc(), mcl_memory_realloc(), MCL_NEW, MCL_NULL, MCL_NULL_CHAR_SIZE, MCL_OK, MCL_OUT_OF_MEMORY, mcl_tls_ca_chain_add_certificate(), mcl_tls_ca_chain_init(), MCL_TRIGGERED_WITH_NULL, MCL_TRUE, mcl_http_client_configuration_t::port, mcl_http_client_configuration_t::proxy_domain, mcl_http_client_configuration_t::proxy_hostname, mcl_http_client_configuration_t::proxy_password, mcl_http_client_configuration_t::proxy_port, mcl_http_client_configuration_t::proxy_type, mcl_http_client_configuration_t::proxy_username, string_util_memcpy(), string_util_strdup(), string_util_strlen(), SUPPORTED_CIPHERS_LIST, and mcl_http_client_configuration_t::user_agent.

Referenced by core_processor_initialize().

Here is the call graph for this function:

Here is the caller graph for this function:

MCL_CORE_EXPORT mcl_error_t mcl_http_client_send ( mcl_http_client_t http_client,
mcl_http_request_t http_request,
mcl_http_response_t **  http_response 
)

This function sends the given request to the pre-configured destination and returns the response using underlying implementation. It is blocking until response is received or timeout occurred.

Parameters
[in]http_clientHTTP client handle.
[in]http_requestHTTP request object.
[out]http_responseHTTP response object.
Returns

Definition at line 125 of file http_client_basic.c.

References _convert_to_mcl_return_code(), _header_list_destroy_callback(), _set_request_options(), mcl_http_client_t::certificate_chain, CONTENT_LENGTH_BUFFER_SIZE, content_length_header, crlf, CRLF_SIZE, mcl_http_client_t::curl, libcurl_payload_t::data, get_response(), mcl_http_request_t::header, https_prefix, HTTPS_PREFIX_SIZE, MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, MCL_FREE, MCL_FUNCTION_LEAVE_LABEL, MCL_HTTP_GET, mcl_http_response_initialize(), MCL_INFO, MCL_INVALID_PARAMETER, mcl_list_destroy_with_content(), mcl_list_initialize(), MCL_NEW, MCL_NULL, MCL_OK, MCL_OPERATION_NOT_SUPPORTED, MCL_OUT_OF_MEMORY, mcl_string_util_snprintf(), mcl_string_util_strncmp(), mcl_tls_socket_destroy(), mcl_tls_socket_init(), mcl_tls_socket_open(), MCL_TLS_SOCKET_PARAMETER_CERTIFICATE_CHAIN, MCL_TLS_SOCKET_PARAMETER_TIMEOUT, mcl_tls_socket_set_parameter(), mcl_http_request_t::method, mcl_http_request_t::payload, mcl_http_request_t::payload_size, send_buffer(), send_header(), send_header_list(), send_with_callback(), libcurl_payload_t::size, start_http(), mcl_http_request_t::stream_callback, mcl_http_request_t::stream_data, mcl_http_client_t::timeout, transfer_encoding_header, TRANSFER_ENCODING_SIZE, mcl_http_request_t::uri, and mcl_http_client_t::user_agent.

Referenced by core_processor_get_access_token(), and core_processor_register().

Here is the call graph for this function:

Here is the caller graph for this function: