WE310F5  39.00.000
m2mb_httpc.h File Reference

This file contains the APIs for HTTP client operations. More...

Go to the source code of this file.

Data Structures

struct  M2MB_HTTPC_RESPONSE
 HTTP client response for use in user callback. More...
 
union  M2MB_HTTPC_CONF_PARAMS
 HTTP client configuration params structure for use in m2mb_http_set_cfg and m2mb_httpc_get_cfg APIs. More...
 
struct  M2MB_HTTPC_CONF_PARAMS::param
 
struct  M2MB_HTTPC_OPEN_PARAMS
 HTTPC parameters required to open a client connection. More...
 
#define M2MB_HTTPCLIENT_MAX_URL_LENGTH   1024
 
#define M2MB_HTTPCLIENT_MAX_HOST_LENGTH   64
 
enum  M2MB_HTTPC_METHODS {
  M2MB_HTTPC_METHOD_INVALID = 0,
  M2MB_HTTPC_METHOD_GET = 1,
  M2MB_HTTPC_METHOD_HEAD,
  M2MB_HTTPC_METHOD_POST,
  M2MB_HTTPC_METHOD_PUT,
  M2MB_HTTPC_METHOD_MAX
}
 supported http request method for use with m2mb_httpc_request. More...
 
enum  M2MB_HTTPC_STATES {
  M2MB_HTTPC_RX_ERROR_SERVER_CLOSED = -8,
  M2MB_HTTPC_RX_ERROR_RX_PROCESS = -7,
  M2MB_HTTPC_RX_ERROR_RX_HTTP_HEADER = -6,
  M2MB_HTTPC_RX_ERROR_INVALID_RESPONSECODE = -5,
  M2MB_HTTPC_RX_ERROR_CLIENT_TIMEOUT = -4,
  M2MB_HTTPC_RX_ERROR_NO_BUFFER = -3,
  M2MB_HTTPC_RX_CONNECTION_CLOSED = -2,
  M2MB_HTTPC_RX_ERROR_CONNECTION_CLOSED = -1,
  M2MB_HTTPC_RX_FINISHED = 0,
  M2MB_HTTPC_RX_MORE_DATA = 1
}
 HTTP client callback state. More...
 
enum  M2MB_HTTPC_CONF_ID {
  M2MB_HTTPC_CONF_INVALID = 0,
  M2MB_HTTPC_CONF_SET_HEADER,
  M2MB_HTTPC_CONF_SET_CGI_PARAMS,
  M2MB_HTTPC_CONF_SET_ENABLE_RESP_HEADER,
  M2MB_HTTPC_CONF_SET_CLEAR_ALL_HEADER,
  M2MB_HTTPC_CONF_SET_TIMEOUT,
  M2MB_HTTPC_CONF_GET_SERVER_IP,
  M2MB_HTTPC_CONF_GET_SOCK_ID
}
 HTTP client confg id for use in m2mb_http_set_cfg and m2mb_httpc_get_cfg APIs. More...
 
typedef HANDLE M2MB_HTTPC_CTXT_HANDLE
 HTTPC context handle.
This is obtained from m2mb_httpc_open API and then used in subsequent HTTPC APIs. More...
 
typedef enum M2MB_HTTPC_METHODS M2MB_HTTPC_METHODS_E
 supported http request method for use with m2mb_httpc_request. More...
 
typedef enum M2MB_HTTPC_STATES M2MB_HTTPC_STATES_E
 HTTP client callback state. More...
 
typedef enum M2MB_HTTPC_CONF_ID M2MB_HTTPC_CONF_ID_E
 HTTP client confg id for use in m2mb_http_set_cfg and m2mb_httpc_get_cfg APIs. More...
 
typedef struct M2MB_HTTPC_RESPONSE M2MB_HTTPC_RESPONSE_T
 HTTP client response for use in user callback. More...
 
typedef VOID(* M2MB_HTTPC_CB_T) (VOID *arg, M2MB_HTTPC_STATES_E state, M2MB_HTTPC_RESPONSE_T *value)
 User registered callback for returning response message. More...
 
typedef union M2MB_HTTPC_CONF_PARAMS M2MB_HTTPC_CONF_PARAMS_T
 HTTP client configuration params structure for use in m2mb_http_set_cfg and m2mb_httpc_get_cfg APIs. More...
 
typedef struct M2MB_HTTPC_OPEN_PARAMS M2MB_HTTPC_OPEN_PARAMS_T
 HTTPC parameters required to open a client connection. More...
 
M2MB_STATUS_T m2mb_httpc_open (HANDLE *hndl, M2MB_HTTPC_OPEN_PARAMS_T *params)
 create http client context More...
 
M2MB_STATUS_T m2mb_httpc_set_cfg (HANDLE handle, M2MB_HTTPC_CONF_ID_E conf_id, M2MB_HTTPC_CONF_PARAMS_T *conf_params)
 update the http client session configurations More...
 
M2MB_STATUS_T m2mb_httpc_get_cfg (HANDLE handle, M2MB_HTTPC_CONF_ID_E conf_id, M2MB_HTTPC_CONF_PARAMS_T *conf_params)
 get the http client session information More...
 
M2MB_STATUS_T m2mb_httpc_connect (HANDLE handle, UINT8 *url, UINT16 port)
 Connects to an HTTP server in Blocking mode. More...
 
M2MB_STATUS_T m2mb_httpc_set_request (VOID *handle, M2MB_HTTPC_METHODS_E method, UINT8 *url)
 Set the http request. More...
 
M2MB_STATUS_T m2mb_httpc_send (VOID *handle, UINT8 isFirstPacket, UINT8 *body, UINT32 body_length, UINT32 total_length)
 Send HTTP information from the http client session. More...
 
M2MB_STATUS_T m2mb_httpc_close (HANDLE handle)
 closes an HTTP client session. More...
 

Detailed Description

This file contains the APIs for HTTP client operations.

epl/inc/nwk/m2mb_httpc.h

This file has APIs for handling HTTP client operations. This modules contains the following APIs.

  1. m2mb_httpc_open()
  2. m2mb_httpc_set_cfg()
    3. m2mb_httpc_set_request()
  3. m2mb_httpc_connect()
  4. m2mb_httpc_get_cfg()
  5. m2mb_httpc_set_request()
  6. m2mb_httpc_send()
  7. m2mb_httpc_close()

The following headers are sent by default during http request.

  1. Host : with given ip/hostname
  2. Accept : text/html
  3. Cache-control: no-cache
  4. User-Agent : IOE Client
  5. Connect: keep-alive
Note
Dependencies:
#include "nwk/m2mb_ssl.h"
#include "m2mb_socket.h"
#include "m2mb_uart.h"
#include "m2mb_dbg.h"
Author
Ranjitakumar Mahapatra
Date
15/09/2018

Definition in file m2mb_httpc.h.