HTTP request module interface header file. More...
#include "mcl_core/mcl_list.h"
Go to the source code of this file.
Data Structures | |
struct | mcl_http_request_t |
Typedefs | |
typedef mcl_size_t(* | mcl_http_payload_callback) (char *buffer, mcl_size_t size, mcl_size_t count, void *user_context) |
Functions | |
MCL_CORE_EXPORT mcl_error_t | mcl_http_request_initialize (mcl_http_request_t **http_request) |
MCL_CORE_EXPORT mcl_error_t | mcl_http_request_add_header (mcl_http_request_t *http_request, const char *header_name, const char *header_value) |
MCL_CORE_EXPORT mcl_error_t | mcl_http_request_set_parameter (mcl_http_request_t *http_request, E_MCL_HTTP_REQUEST_PARAMETER parameter, const void *value) |
MCL_CORE_EXPORT void | mcl_http_request_destroy (mcl_http_request_t **http_request) |
HTTP request module interface header file.
This module is used internally by other MCL modules to prepare an HTTP request before mcl_http_client_send is called. HTTP request (mcl_http_request_t) can be initialized with mcl_http_request_initialize function. Following initialization, header fields can be set with mcl_http_request_add_header function. HTTP request options listed in E_MCL_HTTP_REQUEST_PARAMETER can be set using mcl_http_request_set_parameter function. After HTTP request is sent, it has to be destroyed using mcl_http_request_destroy function.
Definition in file mcl_http_request.h.
typedef mcl_size_t(* mcl_http_payload_callback) (char *buffer, mcl_size_t size, mcl_size_t count, void *user_context) |
Callback function prototype for adding payload to HTTP request.
[in] | buffer | Destination address for payload. |
[in] | size | Size, in bytes, of each element to be read. |
[in] | count | Number of elements, each one with a size of size bytes. |
[in] | user_context | Source address for payload. |
Definition at line 66 of file mcl_http_request.h.
enum E_MCL_HTTP_METHOD |
HTTP method types.
Definition at line 29 of file mcl_http_request.h.
HTTP request options.
Definition at line 46 of file mcl_http_request.h.
MCL_CORE_EXPORT mcl_error_t mcl_http_request_add_header | ( | mcl_http_request_t * | http_request, |
const char * | header_name, | ||
const char * | header_value | ||
) |
This function is used to add an HTTP header to the request with its value.
[in] | http_request | HTTP request handle to be used. |
[in] | header_name | Header name. |
[in] | header_value | Header value. |
http_request
, header_name
or header_value
is NULL. Definition at line 57 of file http_request.c.
References mcl_http_request_t::header, MCL_ASSERT_CODE_MESSAGE, MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, MCL_FUNCTION_LEAVE_LABEL, mcl_list_add(), MCL_MALLOC, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, string_util_snprintf(), and string_util_strlen().
Referenced by core_processor_get_access_token(), and core_processor_register().
MCL_CORE_EXPORT void mcl_http_request_destroy | ( | mcl_http_request_t ** | http_request | ) |
This function destroys HTTP request data structure.
[in] | http_request | HTTP request handle to be freed. |
Definition at line 155 of file http_request.c.
References _http_request_header_destroy(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, mcl_list_destroy_with_content(), and MCL_NULL.
Referenced by core_processor_get_access_token(), core_processor_register(), and mcl_http_request_initialize().
MCL_CORE_EXPORT mcl_error_t mcl_http_request_initialize | ( | mcl_http_request_t ** | http_request | ) |
This function creates and initializes an mcl_http_request_t.
[out] | http_request | The newly initialized HTTP request. |
uri
or http_request
is NULL. Definition at line 18 of file http_request.c.
References MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, MCL_HTTP_GET, mcl_http_request_destroy(), mcl_list_initialize(), MCL_NEW, MCL_NULL, MCL_OK, and MCL_OUT_OF_MEMORY.
Referenced by core_processor_get_access_token(), and core_processor_register().
MCL_CORE_EXPORT mcl_error_t mcl_http_request_set_parameter | ( | mcl_http_request_t * | http_request, |
E_MCL_HTTP_REQUEST_PARAMETER | parameter, | ||
const void * | value | ||
) |
This function is used to set a parameter of HTTP request.
[in] | http_request | HTTP request handle to be used. |
[in] | parameter | One of the parameters listed in E_MCL_HTTP_REQUEST_PARAMETER. |
[in] | value | New value of the parameter . |
http_request
or value
is NULL. parameter
is invalid. Definition at line 97 of file http_request.c.
References MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, MCL_HTTP_END, MCL_HTTP_REQUEST_PARAMETER_BODY, MCL_HTTP_REQUEST_PARAMETER_BODY_SIZE, MCL_HTTP_REQUEST_PARAMETER_METHOD, MCL_HTTP_REQUEST_PARAMETER_STREAM_CALLBACK, MCL_HTTP_REQUEST_PARAMETER_STREAM_DATA, MCL_HTTP_REQUEST_PARAMETER_URL, MCL_INVALID_PARAMETER, MCL_NULL, MCL_OK, mcl_http_request_t::method, mcl_http_request_t::payload, mcl_http_request_t::payload_size, mcl_http_request_t::stream_callback, mcl_http_request_t::stream_data, string_util_reset(), and mcl_http_request_t::uri.
Referenced by core_processor_get_access_token(), and core_processor_register().