![]() |
WE310F5
39.00.000
|
This section describes the M2MB APIs to perform HTTP server operations. More...
This section describes the M2MB APIs to perform HTTP server operations.
#define HTTP_ACCEPTED 202 |
Definition at line 45 of file m2mb_httpd.h.
#define HTTP_CREATED 201 |
Definition at line 44 of file m2mb_httpd.h.
#define HTTP_ERROR_AUTHFAIL 401 |
Definition at line 59 of file m2mb_httpd.h.
#define HTTP_ERROR_BADGATEWAY 502 |
Definition at line 78 of file m2mb_httpd.h.
#define HTTP_ERROR_BADMEDIA 415 |
Definition at line 73 of file m2mb_httpd.h.
#define HTTP_ERROR_BADREQ 400 |
Definition at line 58 of file m2mb_httpd.h.
#define HTTP_ERROR_CONFLICT 409 |
Definition at line 67 of file m2mb_httpd.h.
#define HTTP_ERROR_FORBID 403 |
Definition at line 61 of file m2mb_httpd.h.
#define HTTP_ERROR_GATEAWYTMO 504 |
Definition at line 80 of file m2mb_httpd.h.
#define HTTP_ERROR_HTTPVER 505 |
Definition at line 81 of file m2mb_httpd.h.
#define HTTP_ERROR_LENGTH 411 |
Definition at line 69 of file m2mb_httpd.h.
#define HTTP_ERROR_METHOD 405 |
Definition at line 63 of file m2mb_httpd.h.
#define HTTP_ERROR_NOFILE 404 |
Definition at line 62 of file m2mb_httpd.h.
#define HTTP_ERROR_NOTIMPLEMENTED 501 |
Definition at line 77 of file m2mb_httpd.h.
#define HTTP_ERROR_OVERLOAD 503 |
Definition at line 79 of file m2mb_httpd.h.
#define HTTP_ERROR_PAYMENT 402 |
Definition at line 60 of file m2mb_httpd.h.
#define HTTP_ERROR_PREFAIL 412 |
Definition at line 70 of file m2mb_httpd.h.
#define HTTP_ERROR_PROXYAUT 407 |
Definition at line 65 of file m2mb_httpd.h.
#define HTTP_ERROR_REQTMO 408 |
Definition at line 66 of file m2mb_httpd.h.
#define HTTP_ERROR_RESGONE 410 |
Definition at line 68 of file m2mb_httpd.h.
#define HTTP_ERROR_SERVER 500 |
Definition at line 76 of file m2mb_httpd.h.
#define HTTP_ERROR_TOOBIG 413 |
Definition at line 71 of file m2mb_httpd.h.
#define HTTP_ERROR_UNACCEPT 406 |
Definition at line 64 of file m2mb_httpd.h.
#define HTTP_ERROR_URIBIG 414 |
Definition at line 72 of file m2mb_httpd.h.
#define HTTP_NO_CONTENT 204 |
Definition at line 46 of file m2mb_httpd.h.
#define HTTP_OK 200 |
Definition at line 43 of file m2mb_httpd.h.
#define HTTP_REDIRECT_MULTI 300 |
Definition at line 50 of file m2mb_httpd.h.
#define HTTP_REDIRECT_NOMOD 304 |
Definition at line 54 of file m2mb_httpd.h.
#define HTTP_REDIRECT_OTHER 303 |
Definition at line 53 of file m2mb_httpd.h.
#define HTTP_REDIRECT_PERM 301 |
Definition at line 51 of file m2mb_httpd.h.
#define HTTP_REDIRECT_PROXY 305 |
Definition at line 55 of file m2mb_httpd.h.
#define HTTP_REDIRECT_TEMP 302 |
Definition at line 52 of file m2mb_httpd.h.
#define HTTP_RESET_CONTENT 205 |
Definition at line 47 of file m2mb_httpd.h.
#define M2MB_HTTPD_PATH_MAX 31 |
Maximum length of path
Definition at line 40 of file m2mb_httpd.h.
#define M2MB_HTTPD_SRVR_NAME_MAX 512 |
Maximum length of Server
Definition at line 41 of file m2mb_httpd.h.
typedef enum M2MB_HTTPD_CONF_ID M2MB_HTTPD_CONF_ID_E |
HTTP server GET/SET Configuration enumeration.
This enum defines macros for various GET/SET Configuration for HTTP server module.
typedef struct M2MB_HTTPD_CONFIG_S M2MB_HTTPD_CONFIG_T |
HTTP server configuration structure.
Structure for storing HTTP server configuration. User will fill this structure and give as input to m2mb_httpd_init API to initialize the HTTP server.
typedef struct M2MB_HTTPD_GET_BODY_LOC M2MB_HTTPD_GET_BODY_LOC_T |
The structure is used to GET the pointer to the body locaiton on the request.
This structure is used to GET the pointer to the body locaiton on the URI request with the connection handler.
typedef struct M2MB_HTTPD_GET_CONTENT_LEN M2MB_HTTPD_GET_CONTENT_LEN_T |
The structure is used to GET the content length of the request.
This structure is used to GET the content length of the URI request with the connection handler.
typedef struct M2MB_HTTPD_GET_MSG_INFO M2MB_HTTPD_GET_MSG_INFO_T |
The structure is used to GET the HEAD/BODY information.
This structure is used to GET the data with HEAD/BODY of the URI request with the connection handler.
The structure is used to GET the CGI form data with the URI request.
This structure is used to GET the CGI form data with the URI request on the connection handler.
typedef struct M2MB_HTTPD_GET_REQUEST_TYPE M2MB_HTTPD_GET_REQUEST_TYPE_T |
The structure is used to GET the request type on the connection handler.
This structure is used to GET the request type on the connection handler.
typedef struct M2MB_HTTPD_INIT_PARAMS M2MB_HTTPD_INIT_PARAMS_T |
HTTPD initialization parameters.
Contains information needed to initialize the HTTPD module.
typedef struct M2MB_HTTPD_URI_CONFIG_PARAMS M2MB_HTTPD_URI_CONFIG_PARAMS_T |
This structure is used to set HTTPD URI configuration parameters.
Contains configuration information needed for registring URI.
HTTP server URI Request user call back prototype.
Type definition of the user callback to handle the request received on the configured URI using m2mb_httpd_uri_cfg API. event is defined by M2MB_HTTPD_URI_USER_EVENT_E.
This API configures given URI to the HTTP server running.
[in] | conn_handle | The connection handler of the request. |
[in] | usr_ctx | User context passed while coniguring the URI. |
[in] | event | Event due to which the user callback has been called, and values defined by M2MB_HTTPD_URI_USER_EVENT_E. |
Definition at line 356 of file m2mb_httpd.h.
HTTP server CGI form data structure.
Structure containing members representing CGI form data.
typedef struct M2MB_HTTPD_URI_REQ_CGI_KEY_PAIR M2MB_HTTPD_URI_REQ_CGI_KEY_PAIR_T |
HTTP server CGI parameter pair structure.
Structure containing members representing a pair of CGI parameters.
typedef struct M2MB_HTTPD_URI_REQ_INFO M2MB_HTTPD_URI_REQ_INFO_T |
HTTP server URI Request structure.
Structure containing members representing URI request received.
typedef enum M2MB_HTTPD_URI_USER_EVENT M2MB_HTTPD_URI_USER_EVENT_E |
HTTP server URI user event enumeration.
This enum defines macros for type of user events for URI operations.
typedef struct M2MB_HTTPD_URI_CTX M2MB_HTTPD_URICTX_T |
HTTP server URI context structure.
Structure for storing HTTP server URI context related to particular URI.
typedef struct M2MB_HTTPD_URICTXT_FROM_INDEX M2MB_HTTPD_URICTXT_FROM_INDEX_T |
The structure is used to GET the applicaiton context of the registered URI.
This structure is used to GET the application context of the registered URI with the help of the URI index.
typedef struct M2MB_HTTPD_USER_INFO M2MB_HTTPD_USER_INFO_T |
The structure is used to GET/SET the user information on the HTTPD module.
This structure is used to GET/SET the user information on the HTTPD module.
typedef enum M2MB_URI_AUTH_FLAG M2MB_URI_AUTH_FLAG_T |
HTTP server URI user authentication enumeration.
This enum defines macros for type of user authentication supported for URI.
typedef struct M2MB_URI_CFG_S M2MB_URI_CFG_T |
Return values enumeration.
This enum defines macros for return values of URI callback that are supported by HTTP server.
Enumerator | |
---|---|
FP_ERR | Error |
FP_OK | OK |
FP_FILE | File |
FP_DONE | Done |
Definition at line 90 of file m2mb_httpd.h.
enum M2MB_HTTPD_CONF_ID |
HTTP server GET/SET Configuration enumeration.
This enum defines macros for various GET/SET Configuration for HTTP server module.
Definition at line 378 of file m2mb_httpd.h.
enum M2MB_HTTPD_METHOD_E |
HTTP server request method enumeration.
This enum defines macros for request methods that are supported by HTTP server.
Definition at line 116 of file m2mb_httpd.h.
enum M2MB_HTTPD_MODE_E |
HTTP server operational mode enumeration.
This enum defines macros for operational modes that are supported by HTTP server.
Enumerator | |
---|---|
M2MB_HTTPD_MODE_HTTP | Only nonsecure HTTP. |
M2MB_HTTPD_MODE_HTTPS | Only HTTPS. |
M2MB_HTTPD_MODE_HTTP_AND_HTTPS | Both HTTP and HTTPS. |
Definition at line 104 of file m2mb_httpd.h.
HTTP server URI user event enumeration.
This enum defines macros for type of user events for URI operations.
Definition at line 146 of file m2mb_httpd.h.
enum M2MB_URI_AUTH_FLAG |
HTTP server URI user authentication enumeration.
This enum defines macros for type of user authentication supported for URI.
Enumerator | |
---|---|
M2MB_URI_FLAG_NOAUTH | No authentication |
M2MB_URI_FLAG_AUTHBASIC | check Basic user auth |
M2MB_URI_FLAG_AUTHMD5 | check MD5 user auth |
Definition at line 134 of file m2mb_httpd.h.
M2MB_STATUS_T m2mb_httpd_deinit | ( | HANDLE | handle | ) |
HTTP server deinitialization.
This API deinitializes HTTP server.
[in] | handle | Specifies the pointer to the context handle initialized by m2mb_httpd_init API. |
M2MB_STATUS_T m2mb_httpd_get_cfg | ( | HANDLE | handle, |
M2MB_HTTPD_CONF_ID_E | conf_id, | ||
M2MB_HTTPD_CONF_PARAMS_T * | conf_params | ||
) |
GET the HTTPD configuration parameters.
This API is called to get the configuration of the HTTP server module based on the conf IDs.
[in] | handle | Specifies the pointer to the context handle initialized by m2mb_httpd_init API. |
[in] | conf_id | GET configuration ID form enum M2MB_HTTPD_CONF_ID_E. |
[in] | conf_params | configuration params to be passed according to the configuration required. |
M2MB_URI_CFG_T* m2mb_httpd_get_uri_cfg_from_index | ( | INT32 | index | ) |
Gets the URI configuration.
This API gets the URI configuration of the URI registered with the server at givem URI ID. This API would be used in the callback registered during URI configuration to server (M2MB_HTTPD_URI_HANDLER_T).
[in] | index | Index of the requested URI. |
m2mb_httpd_get_uri_cfg_from_index( index );
M2MB_STATUS_T m2mb_httpd_init | ( | HANDLE * | handle, |
M2MB_HTTPD_INIT_PARAMS_T * | init_params | ||
) |
HTTP server deinitialization.
This API configures and initializes HTTP server. It takes the configuration of the server and SSL handle created using m2mb_ssl_open API as the input.
[in] | handle | Specifies the pointer to the context handle that can be used by other HTTP server APIs. |
[in] | init_params | Pointer to initialization parameters required for HTTP server module initialization. |
m2mb_httpd_init( &handle, &init_params );
M2MB_STATUS_T m2mb_httpd_send_data | ( | VOID * | conn_handle, |
const INT8 * | data, | ||
UINT32 | length | ||
) |
Send HTTP data.
This API sends the HTTP data to client after receiving request from the client on a configured URI. This API would be used in the callback registered during URI configuration to server (M2MB_HTTPD_URI_HANDLER_T).
[in] | conn_handle | Pointer representing the HTTP server handle. |
[in] | data | Data going in the response from Server to Client as the content. |
[in] | length | An integer mentioning the length of the content going in the response from Server to Client. |
m2mb_httpd_send_http_data( hp, "0123456789", 10 );
M2MB_STATUS_T m2mb_httpd_send_headers | ( | VOID * | conn_handle, |
UINT8 * | content_type, | ||
INT32 | content_length, | ||
INT32 | status_code, | ||
UINT8 * | status_text, | ||
UINT8 * | user_headers | ||
) |
Send HTTP headers.
This API sends the HTTP headers to the client after receiving a request from the client on a configured URI. This API would be used in the callback registered during URI configuration to server (M2MB_HTTPD_URI_HANDLER_T).
[in] | conn_handle | Pointer representing the HTTP server handle. |
[in] | content_type | String mentioning the type of content going in the response from Server to Client. |
[in] | content_length | An integer mentioning the length of the content going in the response from Server to Client. |
[in] | status_code | Status code defining the response from the server. Please refer to generic status codes the HTTP server support. |
[in] | status_text | User defined status string corresponding to the status code. |
[in] | user_headers | User defined headers in a string format. Every header should be separated by CR+LF. |
m2mb_httpd_send_headers( hp, "test/plain", 100, 200, "SUCCESS", "" );
M2MB_STATUS_T m2mb_httpd_set_cfg | ( | HANDLE | handle, |
M2MB_HTTPD_CONF_ID_E | conf_id, | ||
M2MB_HTTPD_CONF_PARAMS_T * | conf_params | ||
) |
SET the HTTPD configuration parameters.
This API is called to configure the HTTP server module based on the conf IDs.
[in] | handle | Specifies the pointer to the context handle initialized by m2mb_httpd_init API. |
[in] | conf_id | SET configuration ID form enum M2MB_HTTPD_CONF_ID_E. |
[in] | conf_params | configuration params to be passed according to the configuration to be done. |
M2MB_STATUS_T m2mb_httpd_start | ( | HANDLE | handle | ) |
Start HTTP server.
This API starts HTTP server.
[in] | handle | Specifies the pointer to the context handle initialized by m2mb_httpd_init API. |
m2mb_httpd_start(handle);
M2MB_STATUS_T m2mb_httpd_stop | ( | HANDLE | handle | ) |
Stop HTTP server.
This API stops HTTP server.
[in] | handle | Specifies the pointer to the context handle initialized by m2mb_httpd_init API. |
m2mb_httpd_stop( handle );