![]() |
WL865E4-P
36.07.001
|
This section describes the M2MB APIs to HTTP Client operations. More...
This section describes the M2MB APIs to HTTP Client operations.
#define HTTPCLIENT_MAX_URL_LENGTH 128 |
Definition at line 134 of file m2mb_httpc.h.
#define M2MB_HTTPC_DBG_PRINTF m2mb_dbg_consol_print |
Definition at line 52 of file m2mb_httpc.h.
#define M2MB_HTTPC_DEBUG_PRINT_ENABLE |
Definition at line 49 of file m2mb_httpc.h.
User registered callback for returning response message.
[in] | arg | Argument passed in |
[in] | state | State in M2MB_HTTPC_STATES_E |
[in] | value | Pointer to M2MB_HTTPC_RESPONSE_T |
Definition at line 147 of file m2mb_httpc.h.
typedef struct M2MB_HTTPC_CTX M2MB_HTTPC_CTX_T |
HTTP Client context
typedef enum M2MB_HTTPC_METHODS M2MB_HTTPC_METHODS_E |
For use with m2mb_httpc_request.
typedef struct M2MB_HTTPC_RESPONSE M2MB_HTTPC_RESPONSE_T |
HTTP client response.
typedef enum M2MB_HTTPC_RESULT M2MB_HTTPC_RESULT_E |
typedef enum M2MB_HTTPC_STATES M2MB_HTTPC_STATES_E |
HTTP client callback state.
enum M2MB_HTTPC_METHODS |
For use with m2mb_httpc_request.
Definition at line 79 of file m2mb_httpc.h.
enum M2MB_HTTPC_RESULT |
Definition at line 58 of file m2mb_httpc.h.
enum M2MB_HTTPC_STATES |
HTTP client callback state.
Definition at line 97 of file m2mb_httpc.h.
M2MB_HTTPC_RESULT_E m2mb_httpc_clear_all_headers | ( | VOID * | handle | ) |
Clears the header field for an HTTP client session.
[in] | handle | HTTP client session handle. |
Example
M2MB_HTTPC_RESULT_E m2mb_httpc_connect | ( | VOID * | handle, |
UINT8 * | url, | ||
UINT16 | port | ||
) |
Connects to an HTTP server in Blocking mode.
[in] | handle | HTTP client session handle. |
[in] | url | Pointer to server or proxy, e.g. "192.168.2.100" or "www.example.com" |
[in] | port | Port of the server. |
Example
M2MB_HTTPC_RESULT_E m2mb_httpc_disconnect | ( | VOID * | handle | ) |
Disconnects from an HTTP server .
[in] | handle | HTTP client session handle. |
Example
M2MB_HTTPC_RESULT_E m2mb_httpc_enable_http_response_header | ( | VOID * | handle, |
UINT16 | enable | ||
) |
Enables/disables the addition of an HTTP header in a session callback.
By default, the system returns the message body of response via user registered callback (see M2MB_HTTPC_CB_T). Message headers are not returned. To enable the system to also return messages headers, this API should be called with 'enable'= 1.
[in] | handle | HTTP client session handle. |
[in] | enable | 1 – enable; 0 – disable. |
Example
M2MB_HTTPC_RESULT_E m2mb_httpc_request | ( | VOID * | handle, |
M2MB_HTTPC_METHODS_E | method, | ||
UINT8 * | url | ||
) |
Send an HTTP request to an HTTP server or proxy.
[in] | handle | HTTP client session handle. |
[in] | method | HTTP request (see M2MB_HTTPC_METHODS_E) |
[in] | url | Pointer to the request URL, e.g. "index.html" or "/cgi/mycgi.pl" |
Example
M2MB_HTTPC_RESULT_E m2mb_httpc_send | ( | VOID * | handle, |
UINT8 | isFirstPacket, | ||
UINT8 * | body, | ||
UINT32 | body_length, | ||
UINT32 | total_length | ||
) |
Send HTTP information from the http client session.
[in] | handle | HTTP client session handle. |
[in] | isFirstPacket | is Firstpacket Flag |
[in] | body | is data body |
[in] | body_length | is data body length |
[in] | total_length | is total body length |
Example
M2MB_HTTPC_RESULT_E m2mb_httpc_session_abort | ( | VOID * | handle | ) |
Aborts an HTTP client session.
Disconnects from the server and frees the memory.
[in] | handle | HTTP client session handle. |
Example
VOID* m2mb_httpc_session_create | ( | UINT32 | timeout, |
M2MB_HTTPC_CB_T | cb, | ||
VOID * | cb_arg, | ||
UINT16 | httpc_max_body_len, | ||
UINT16 | httpc_max_Header_len, | ||
UINT16 | httpc_Rx_Buffer_Size, | ||
VOID * | m2mbSslCtx | ||
) |
create http client session.
This API creates a new http client session.
[in] | timeout | HTTP client session Timeout. |
[in] | cb | Pointer to HTTP client session callback function. |
[in] | cb_arg | Pointer to the HTTP client session callback context |
[in] | httpc_max_body_len | HTTP client session max body length. |
[in] | httpc_max_Header_len | HTTP client session max header length. |
[in] | httpc_Rx_Buffer_Size | HTTP client session receive buffer size. |
[in] | m2mbSslCtx | pointer to SSL context. |
Example
M2MB_HTTPC_RESULT_E m2mb_httpc_session_getInfo | ( | VOID * | handle, |
M2MB_IP46_ADDR_T * | ipv6, | ||
INT32 * | socket | ||
) |
Sets HTTP socket information from the http client session.
[in] | handle | HTTP client session handle. |
[in] | ipv6 | or ipv4 IP address information. |
[in] | socket | information. |
Example
M2MB_HTTPC_RESULT_E m2mb_httpc_set_cgi_params | ( | VOID * | handle, |
UINT8 * | arg, | ||
UINT8 * | value | ||
) |
Forms a URL-encoded string on an HTTP client session.
[in] | handle | HTTP client session handle. |
[in] | arg | Pointer to the key. |
[in] | value | Pointer to the value. |
M2MB_HTTPC_RESULT_E m2mb_httpc_set_header | ( | VOID * | handle, |
UINT8 * | hdr_name, | ||
UINT8 * | hdr_value | ||
) |
Sets the header field for an HTTP client session.
[in] | handle | HTTP client session handle. |
[in] | hdr_name | Pointer to the type. |
[in] | hdr_value | Pointer to the value. |
Additionally, for POST, PUT and PATCH requests if message body has data:
If this API is called, the system will send the following headers for user:
Additionally, for POST, PUT and PATCH requests if message body has data:
Example
M2MB_HTTPC_RESULT_E m2mb_httpc_set_request | ( | VOID * | handle, |
M2MB_HTTPC_METHODS_E | method, | ||
UINT8 * | url | ||
) |
Set the http request.
[in] | handle | HTTP client session handle. |
[in] | method | |
[in] | url |
Example
M2MB_HTTPC_RESULT_E m2mb_httpc_set_request_body | ( | VOID * | handle, |
UINT8 * | body, | ||
UINT32 | body_length, | ||
UINT32 | total_length | ||
) |
Sets the body on an HTTP client session.
[in] | handle | HTTP client session handle. |
[in] | body | Pointer to the http message body. |
[in] | body_length | Length of the current http message body. |
[in] | total_length | total length of http message. |
M2MB_HTTPC_RESULT_E m2mb_httpc_start | ( | ) |
(Re)starts the HTTP client module.
Normally, this is called to start or restart the client after it was stopped via a call to m2mb_httpc_stop().
Example
M2MB_HTTPC_RESULT_E m2mb_httpc_stop | ( | ) |
Stops the HTTP client module.
Example