http_response.h File Reference

HTTP response module header file. More...

#include "string_array.h"
Include dependency graph for http_response.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  http_response_t
 HTTP Response Handle. More...
 

Enumerations

enum  E_MCL_HTTP_RESULT_CODE {
  MCL_HTTP_RESULT_CODE_UNKNOWN = 0, MCL_HTTP_RESULT_CODE_GENERAL_INFORMATION_1XX = 1, MCL_HTTP_RESULT_CODE_CONTINUE = 100, MCL_HTTP_RESULT_CODE_GENERAL_SUCCESSFUL_2XX = 2,
  MCL_HTTP_RESULT_CODE_SUCCESS = 200, MCL_HTTP_RESULT_CODE_CREATED = 201, MCL_HTTP_RESULT_CODE_PARTIAL_CONTENT = 206, MCL_HTTP_RESULT_CODE_GENERAL_REDIRECTION_3XX = 3,
  MCL_HTTP_RESULT_CODE_MOVED_PERMANENTLY = 301, MCL_HTTP_RESULT_CODE_USE_PROXY = 305, MCL_HTTP_RESULT_CODE_GENERAL_CLIENT_ERROR_4XX = 4, MCL_HTTP_RESULT_CODE_BAD_REQUEST = 400,
  MCL_HTTP_RESULT_CODE_UNAUTHORIZED = 401, MCL_HTTP_RESULT_CODE_FORBIDDEN = 403, MCL_HTTP_RESULT_CODE_NOT_FOUND = 404, MCL_HTTP_RESULT_CODE_METHOD_NOT_ALLOWED = 405,
  MCL_HTTP_RESULT_CODE_PROXY_AUTH_REQUIRED = 407, MCL_HTTP_RESULT_CODE_REQUEST_TIMEOUT = 408, MCL_HTTP_RESULT_CODE_CONFLICT = 409, MCL_HTTP_RESULT_CODE_PRECONDITION_FAILED = 412,
  MCL_HTTP_RESULT_CODE_PAYLOAD_TOO_LARGE = 413, MCL_HTTP_RESULT_CODE_TOO_MANY_REQUESTS = 429, MCL_HTTP_RESULT_CODE_GENERAL_SERVER_ERROR_5XX = 5, MCL_HTTP_RESULT_CODE_INTERNAL_SERVER_ERR = 500,
  MCL_HTTP_RESULT_CODE_NOT_IMPLEMENTED = 501, MCL_HTTP_RESULT_CODE_BAD_GATEWAY = 502, MCL_HTTP_RESULT_CODE_SERVICE_UNAVAILABLE = 503, MCL_HTTP_RESULT_CODE_GATEWAY_TIMEOUT = 504,
  MCL_HTTP_RESULT_CODE_HTTP_VERSION_NOT_SUPPORTED = 505
}
 HTTP Result Codes. More...
 

Functions

E_MCL_ERROR_CODE http_response_initialize (string_array_t *header, mcl_uint8_t *payload, mcl_size_t payload_size, E_MCL_HTTP_RESULT_CODE result_code, http_response_t **http_response)
 HTTP Response Module Initialize function. More...
 
E_MCL_ERROR_CODE http_response_get_header (http_response_t *http_response, char *header_name, string_t **header_value)
 Get the value of a specified HTTP Header. More...
 
mcl_uint8_thttp_response_get_payload (http_response_t *http_response)
 Get the payload section of the HTTP Response. More...
 
E_MCL_HTTP_RESULT_CODE http_response_get_result_code (http_response_t *http_response)
 Get the result code of the HTTTP Response. More...
 
void http_response_destroy (http_response_t **http_response)
 To destroy the HTTP Response Handler. More...
 

Detailed Description

HTTP response module header file.


Date
Jul 19, 2016 This module analyzes and parses received HTTP response messages.

Definition in file http_response.h.

Enumeration Type Documentation

HTTP Result Codes.

Only most used result codes are defined. For non existing ones, the general group names will be used ( e.g. MCL_HTTP_RESULT_CODE_GENERAL_REDIRECTION_3XX )

Enumerator
MCL_HTTP_RESULT_CODE_UNKNOWN 

Unknown result code.

MCL_HTTP_RESULT_CODE_GENERAL_INFORMATION_1XX 

General Group Name for 1xx Error Codes.

MCL_HTTP_RESULT_CODE_CONTINUE 

Actual code : 100.

MCL_HTTP_RESULT_CODE_GENERAL_SUCCESSFUL_2XX 

General Group Name for 2xx Error Codes.

MCL_HTTP_RESULT_CODE_SUCCESS 

Actual code : 200.

MCL_HTTP_RESULT_CODE_CREATED 

Actual code : 201.

MCL_HTTP_RESULT_CODE_PARTIAL_CONTENT 

Actual code : 206.

MCL_HTTP_RESULT_CODE_GENERAL_REDIRECTION_3XX 

General Group Name for 3xx Error Codes.

MCL_HTTP_RESULT_CODE_MOVED_PERMANENTLY 

Actual code : 301.

MCL_HTTP_RESULT_CODE_USE_PROXY 

Actual code : 305.

MCL_HTTP_RESULT_CODE_GENERAL_CLIENT_ERROR_4XX 

General Group Name for 4xx Error Codes.

MCL_HTTP_RESULT_CODE_BAD_REQUEST 

Actual code : 400.

MCL_HTTP_RESULT_CODE_UNAUTHORIZED 

Actual code : 401.

MCL_HTTP_RESULT_CODE_FORBIDDEN 

Actual code : 403.

MCL_HTTP_RESULT_CODE_NOT_FOUND 

Actual code : 404.

MCL_HTTP_RESULT_CODE_METHOD_NOT_ALLOWED 

Actual code : 405.

MCL_HTTP_RESULT_CODE_PROXY_AUTH_REQUIRED 

Actual code : 407.

MCL_HTTP_RESULT_CODE_REQUEST_TIMEOUT 

Actual code : 408.

MCL_HTTP_RESULT_CODE_CONFLICT 

Actual code : 409.

MCL_HTTP_RESULT_CODE_PRECONDITION_FAILED 

Actual code : 412.

MCL_HTTP_RESULT_CODE_PAYLOAD_TOO_LARGE 

Actual code : 413.

MCL_HTTP_RESULT_CODE_TOO_MANY_REQUESTS 

Actual code : 429.

MCL_HTTP_RESULT_CODE_GENERAL_SERVER_ERROR_5XX 

General Group Name for 5xx Error Codes.

MCL_HTTP_RESULT_CODE_INTERNAL_SERVER_ERR 

Actual code : 500.

MCL_HTTP_RESULT_CODE_NOT_IMPLEMENTED 

Actual code : 501.

MCL_HTTP_RESULT_CODE_BAD_GATEWAY 

Actual code : 502.

MCL_HTTP_RESULT_CODE_SERVICE_UNAVAILABLE 

Actual code : 503.

MCL_HTTP_RESULT_CODE_GATEWAY_TIMEOUT 

Actual code : 504.

MCL_HTTP_RESULT_CODE_HTTP_VERSION_NOT_SUPPORTED 

Actual code : 505.

Definition at line 26 of file http_response.h.

Function Documentation

void http_response_destroy ( http_response_t **  http_response)

To destroy the HTTP Response Handler.

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

Parameters
[in]http_responseHTTP Response Handle.

Definition at line 99 of file http_response.c.

References DEBUG_ENTRY, DEBUG_LEAVE, MCL_DEBUG, MCL_FREE, MCL_NULL, and string_array_destroy().

Referenced by _exchange_evaluate_response(), http_processor_get_access_token(), and http_processor_register().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE http_response_get_header ( http_response_t http_response,
char *  header_name,
string_t **  header_value 
)

Get the value of a specified HTTP Header.

Parameters
[in]http_responseHTTP Response handle to be used.
[in]header_nameName of the header whose value is requested.
[out]header_valueValur of the header will be stored in header_value.

Definition at line 38 of file http_response.c.

References ASSERT_CODE, ASSERT_CODE_MESSAGE, string_t::buffer, mcl_list_t::count, mcl_list_node_t::data, DEBUG_ENTRY, DEBUG_LEAVE, mcl_list_t::head, http_response_t::header, string_array_t::index, list_destroy_with_content(), MCL_DEBUG, MCL_FAIL, MCL_NULL, MCL_OK, MCL_TRUE, mcl_list_node_t::next, string_array_get(), string_destroy(), string_initialize(), string_split(), and string_util_find_case_insensitive().

Referenced by _process_registration_response_rsa_3072(), and http_processor_get_access_token().

Here is the call graph for this function:

Here is the caller graph for this function:

mcl_uint8_t* http_response_get_payload ( http_response_t http_response)

Get the payload section of the HTTP Response.

Parameters
[in]http_responseHTTP Response handle to be used.
Returns
Returns the pointer to the payload of http_response.

Definition at line 83 of file http_response.c.

References DEBUG_ENTRY, DEBUG_LEAVE, and http_response_t::payload.

Referenced by _process_registration_response_rsa_3072(), _process_registration_response_shared_secret(), and http_processor_get_access_token().

Here is the caller graph for this function:

E_MCL_HTTP_RESULT_CODE http_response_get_result_code ( http_response_t http_response)

Get the result code of the HTTTP Response.

Parameters
[in]http_responseHTTP Response handle to be used.
Returns
HTTP Result Code.

Definition at line 91 of file http_response.c.

References DEBUG_ENTRY, DEBUG_LEAVE, and http_response_t::result_code.

E_MCL_ERROR_CODE http_response_initialize ( string_array_t header,
mcl_uint8_t payload,
mcl_size_t  payload_size,
E_MCL_HTTP_RESULT_CODE  result_code,
http_response_t **  http_response 
)

HTTP Response Module Initialize function.

Create and initializes an http_response_t object and sets its result code if not received.

Parameters
[in]headerString array for the received HTTP Header.
[in]payloadThe received HTTP Payload.
[in]payload_sizeSize of payload.
[in]result_codeThe received status code. If this is 0, http_response_initialize will extract the result code from the message itself.
[out]http_responseHandle of the initialized http_response_t object.
Returns

Definition at line 19 of file http_response.c.

References ASSERT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, MCL_NEW, MCL_NULL, MCL_OK, and MCL_OUT_OF_MEMORY.

Referenced by http_client_send().

Here is the caller graph for this function: