http_processor.h File Reference

HTTP processor module header file. More...

#include "store.h"
#include "http_client.h"
#include "security_handler.h"
#include "jwt.h"
#include "file.h"
#include "event_list.h"
Include dependency graph for http_processor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  http_processor_t
 
struct  http_processor_stream_callback_context_t
 
struct  raw_data_context_t
 

Functions

E_MCL_ERROR_CODE http_processor_initialize (configuration_t *configuration, http_processor_t **http_processor)
 Http Processor Initialize function. More...
 
E_MCL_ERROR_CODE http_processor_register (http_processor_t *http_processor)
 
E_MCL_ERROR_CODE http_processor_update_security_information (http_processor_t *http_processor)
 
E_MCL_ERROR_CODE http_processor_get_access_token (http_processor_t *http_processor)
 
E_MCL_ERROR_CODE http_processor_exchange (http_processor_t *http_processor, store_t *store, void **reserved)
 Exchange operation logic. More...
 
E_MCL_ERROR_CODE http_processor_stream (http_processor_t *http_processor, store_t *store, void **reserved)
 Exchange operation logic with streaming. More...
 
void http_processor_destroy (http_processor_t **http_processor)
 To destroy the HTTP Processor Handler. More...
 

Detailed Description

HTTP processor module header file.


Date
Jul 19, 2016 This module has the center responsibility of running logic of MCL. It manages the collection of the data stored in store_t, generation of HTTP request messages, performing send/receive operations and parsing the HTTP response message.

Definition in file http_processor.h.

Function Documentation

void http_processor_destroy ( http_processor_t **  http_processor)

To destroy the HTTP Processor Handler.

Will release the resources of HTTP Processor. After destroy operation, handler shouldn't be used.

Parameters
[in]http_processorHTTP Processor handle to be destroyed.

Definition at line 946 of file http_processor.c.

References DEBUG_ENTRY, DEBUG_LEAVE, http_client_destroy(), MCL_DEBUG, MCL_FREE, MCL_NULL, security_handler_destroy(), and string_destroy().

Referenced by http_processor_initialize(), and mcl_communication_destroy().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE http_processor_exchange ( http_processor_t http_processor,
store_t store,
void **  reserved 
)

Exchange operation logic.

Performs exchange operation on MindSphere. After successfully sending the data from the received store object, data will be removed.

Parameters
[in]http_processorHTTP Processor handle to be used.
[in]storeThe data to be exchanged will be read from this store.
[out]reservedReserved for future use.
Returns

Definition at line 786 of file http_processor.c.

References _exchange_evaluate_response(), _exchange_fill_http_request(), _exchange_initialize_http_request_headers(), _generate_correlation_id_string(), ASSERT_CODE_MESSAGE, http_processor_t::configuration, mcl_list_t::count, DEBUG_ENTRY, DEBUG_LEAVE, configuration_t::exchange_endpoint, store_t::high_priority_list, http_processor_t::http_client, http_client_send(), HTTP_HEADER_CORRELATION_ID, http_header_names, http_request_add_header(), http_request_destroy(), http_request_initialize(), HTTP_REQUEST_RESIZE_ENABLED, store_t::low_priority_list, configuration_t::max_http_payload_size, MCL_DEBUG, MCL_ERROR_RETURN, MCL_HTTP_POST, MCL_NULL, MCL_OK, MCL_STORE_IS_EMPTY, MCL_TRUE, store_get_data_count(), string_destroy(), and configuration_t::user_agent.

Referenced by mcl_communication_exchange().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE http_processor_get_access_token ( http_processor_t http_processor)

This function is called by mcl_communication_get_access_token().

See also
mcl_communication_get_access_token for details.
Parameters
[in]http_processorHTTP Processor handle to be used.
Returns

Definition at line 580 of file http_processor.c.

References _add_authentication_header_to_request(), _compose_access_token_request_payload(), _concatenate_host_and_endpoint(), _evaluate_response_codes(), _generate_correlation_id_string(), security_handler_t::access_token, configuration_t::access_token_endpoint, ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, string_t::buffer, http_processor_t::configuration, CONTENT_TYPE_URL_ENCODED, content_type_values, DEBUG_ENTRY, DEBUG_LEAVE, ENDPOINT_URI_DOWNLOAD, file_destroy(), file_initialize(), http_processor_t::http_client, http_client_send(), HTTP_HEADER_ACCEPT, HTTP_HEADER_CONTENT_DISPOSITION, HTTP_HEADER_CONTENT_TYPE, HTTP_HEADER_CORRELATION_ID, http_header_names, HTTP_HEADER_SERVER_TIME, http_request_add_header(), http_request_destroy(), http_request_initialize(), HTTP_REQUEST_RESIZE_ENABLED, http_response_destroy(), http_response_get_header(), http_response_get_payload(), JSON_NAME_ACCESS_TOKEN, json_util_destroy(), json_util_get_object_item(), json_util_get_string(), json_util_parse_with_size(), security_handler_t::last_token_time, string_t::length, configuration_t::max_http_payload_size, MCL_BUFFER_OVERFLOW_ERROR, MCL_ERROR, MCL_ERROR_RETURN, MCL_FAIL, MCL_FREE, MCL_HTTP_GET, MCL_HTTP_POST, MCL_INFO, MCL_NULL, MCL_OK, MCL_PARTIAL_CONTENT, MCL_TRUE, configuration_t::mindsphere_hostname, http_response_t::payload, http_request_t::payload, http_response_t::payload_size, http_processor_t::security_handler, string_destroy(), string_initialize_static(), string_util_memcpy(), and configuration_t::user_agent.

Referenced by mcl_communication_get_access_token(), mcl_communication_onboard(), mcl_communication_rotate_key(), and mcl_communication_update_security_information().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE http_processor_initialize ( configuration_t configuration,
http_processor_t **  http_processor 
)

Http Processor Initialize function.

Performs creation and initializations of following modules :

  • security_handler
  • jwt
  • http_client
Parameters
[in]configurationThe configuration parameters to be used for initializing itself and other modules.
[out]http_processorThe newly initialized HTTP processor.
Returns

Definition at line 196 of file http_processor.c.

References _check_file_path(), _concatenate_host_and_endpoint(), _custom_load_register_info(), ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, ENDPOINT_URI_ACCESS_TOKEN, ENDPOINT_URI_EXCHANGE, ENDPOINT_URI_REGISTER, http_client_initialize(), http_processor_destroy(), json_util_initialize_json_library(), MCL_DEBUG, MCL_ERROR, MCL_INFO, MCL_NEW, MCL_NO_ACCESS_TOKEN_PROVIDED, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_PATH_NOT_ACCESSIBLE, MCL_REGISTRATION_INFO_IS_NOT_LOADED, MCL_SECURITY_RSA_3072, MCL_SECURITY_SHARED_SECRET, security_handler_generate_rsa_key(), security_handler_initialize(), security_initialize(), storage_load_rsa_registration_information(), and storage_load_shared_secret_registration_information().

Referenced by mcl_communication_initialize().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE http_processor_register ( http_processor_t http_processor)

This function is called by mcl_communication_onboard() and mcl_communication_rotate_key().

See also
mcl_communication_onboard and
mcl_communication_rotate_key for details.
Parameters
[in]http_processorHTTP Processor handle to be used.
Returns

Definition at line 323 of file http_processor.c.

References _compose_rsa_key_rotation_json(), _compose_rsa_onboarding_json(), _evaluate_response_codes(), _generate_correlation_id_string(), _process_registration_response_rsa_3072(), _process_registration_response_shared_secret(), _save_registration_information(), ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, string_t::buffer, security_handler_t::client_id, http_processor_t::configuration, CONTENT_TYPE_APPLICATION_JSON, content_type_values, DEBUG_ENTRY, DEBUG_LEAVE, http_processor_t::http_client, http_client_send(), HTTP_HEADER_ACCEPT, HTTP_HEADER_AUTHORIZATION, HTTP_HEADER_CONTENT_TYPE, HTTP_HEADER_CORRELATION_ID, http_header_names, http_request_add_header(), http_request_destroy(), http_request_initialize(), HTTP_REQUEST_RESIZE_ENABLED, http_response_destroy(), configuration_t::initial_access_token, string_t::length, configuration_t::max_http_payload_size, MCL_CREATED, MCL_ERROR, MCL_ERROR_RETURN, MCL_FAIL, MCL_HTTP_POST, MCL_HTTP_PUT, MCL_INFO, MCL_NULL, MCL_OK, MCL_SECURITY_RSA_3072, MCL_SECURITY_SHARED_SECRET, MCL_UNEXPECTED_RESULT_CODE, http_request_t::payload, security_handler_t::registration_access_token, security_handler_t::registration_client_uri, configuration_t::registration_endpoint, http_processor_t::security_handler, configuration_t::security_profile, string_destroy(), string_initialize_new(), string_util_memcpy(), string_util_snprintf(), and configuration_t::user_agent.

Referenced by mcl_communication_onboard(), and mcl_communication_rotate_key().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE http_processor_stream ( http_processor_t http_processor,
store_t store,
void **  reserved 
)

Exchange operation logic with streaming.

Performs exchange operation on MindSphere using the http transfer-encoding method. This method directly writes the data to the request buffer while performing the send operation, this way uses less memory than normal exchange method, hence it is suitable sending large data in resource constrained systems. Also this is the only way to send unknown size data, which represented in MCL as stream_data_t.

Warning
The store passed to this method must be a streamable store (mcl_store_initialize() ) .
Parameters
[in]http_processorHTTP Processor handle to be used
[in]storeThe data to be exchanged will be read from this store.
[out]reservedReserved for future use.

Definition at line 870 of file http_processor.c.

References _exchange_evaluate_response(), _exchange_initialize_http_request_headers(), _generate_correlation_id_string(), ASSERT_CODE_MESSAGE, http_processor_t::configuration, mcl_list_t::count, DEBUG_ENTRY, DEBUG_LEAVE, configuration_t::exchange_endpoint, store_t::high_priority_list, http_processor_t::http_client, http_client_send(), HTTP_HEADER_CORRELATION_ID, http_header_names, http_request_add_header(), http_request_destroy(), http_request_initialize(), HTTP_REQUEST_RESIZE_DISABLED, store_t::low_priority_list, configuration_t::max_http_payload_size, MCL_DEBUG, MCL_ERROR_RETURN, MCL_FAIL, MCL_HTTP_POST, MCL_NULL, MCL_OK, MCL_OPERATION_IS_NOT_SUPPORTED, MCL_STORE_IS_EMPTY, MCL_TRUE, http_client_send_callback_info_t::read_callback, http_processor_stream_callback_context_t::request, store_get_data_count(), string_destroy(), configuration_t::user_agent, and http_client_send_callback_info_t::user_context.

Referenced by mcl_communication_exchange().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE http_processor_update_security_information ( http_processor_t http_processor)

This function is called by mcl_communication_update_security_information().

See also
mcl_communication_update_security_information for details.
Parameters
[in]http_processorHTTP Processor handle to be used.
Returns

Definition at line 459 of file http_processor.c.

References ASSERT_CODE_MESSAGE, string_t::buffer, security_handler_t::client_id, security_handler_t::client_secret, http_processor_t::configuration, DEBUG_ENTRY, DEBUG_LEAVE, configuration_t::load_function, MCL_FAIL, MCL_FREE, MCL_NULL, MCL_OK, MCL_SECURITY_SHARED_SECRET, MCL_SECURITY_UP_TO_DATE, MCL_TRUE, rsa_t::private_key, rsa_t::public_key, security_handler_t::registration_access_token, security_handler_t::rsa, mcl_load_registration_information_callback_t::rsa, configuration_t::save_function, http_processor_t::security_handler, configuration_t::security_profile, mcl_load_registration_information_callback_t::shared_secret, mcl_save_registration_information_callback_t::shared_secret, storage_load_rsa_registration_information(), storage_load_shared_secret_registration_information(), configuration_t::store_path, string_compare_with_cstr(), string_destroy(), string_initialize_dynamic(), string_util_strlen(), and string_util_strncmp().

Referenced by mcl_communication_update_security_information().

Here is the call graph for this function:

Here is the caller graph for this function: