/
HTTP Client Request Object Setup
HTTP Client Request Object Setup
Request's Parameters
µC/HTTP-client provides the function HTTPc_ReqSetParam to configure parameters related to the HTTP Request. The function takes as argument the type of parameter and the pointer to the parameter. The below parameter's types are available :
HTTPc Request's Parameters
Parameter Type | Description |
---|---|
HTTPc_PARAM_TYPE_REQ_QUERY_STR_TBL | Sets the Request's Query String Table. |
HTTPc_PARAM_TYPE_REQ_QUERY_STR_HOOK | Sets the Request's Query String Hook Function. |
HTTPc_PARAM_TYPE_REQ_HDR_TBL | Sets the Request's Header Table. |
HTTPc_PARAM_TYPE_REQ_HDR_HOOK | Sets the Request's Header Hook Function. |
HTTPc_PARAM_TYPE_REQ_FORM_TBL | Sets the Request's Form Table. |
HTTPc_PARAM_TYPE_REQ_BODY_CONTENT_TYPE | Sets the Request's Body Content Type. |
HTTPc_PARAM_TYPE_REQ_BODY_CONTENT_LEN | Sets the Request's Body Content Length. |
HTTPc_PARAM_TYPE_REQ_BODY_HOOK | Sets the Request's Hook Function for retrieving the data body. |
HTTPc_PARAM_TYPE_RESP_HDR_HOOK | Sets the Response's Header Hook Function. |
HTTPc_PARAM_TYPE_RESP_BODY_HOOK | Sets the Response's Hook Function for the Body received. |
HTTPc_PARAM_TYPE_TRANS_COMPLETE_CALLBACK | Sets the HTTP Transaction Complete Callback to notify the application that the Transaction is completed. This parameter is mandatory when the |
HTTPc_PARAM_TYPE_TRANS_ERR_CALLBACK | Sets the HTTP Transaction Error Callback to notify the application when an unexpected error occurred with an HTTP Transaction. This parameter is mandatory when the |
Example
Request setup example code
CPU_BOOLEAN HTTPcApp_ReqPrepare (HTTPc_CONN_OBJ *p_req) { HTTPc_ERR err; /* ----------------- INIT NEW REQUEST ----------------- */ HTTPc_ReqClr(p_req, &err); if (err != HTTPc_ERR_NONE) { return (DEF_FAIL); } /* ------------ SET STRING QUERY PARAMETERS ----------- */ HTTPc_ReqSetParam(p_req, HTTPc_PARAM_TYPE_REQ_QUERY_STR_HOOK, &HTTPcApp_ReqQueryStrHook, &err); if (err != HTTPc_ERR_NONE) { return (DEF_FAIL); } /* ---------- SET REQUEST ADDITIONAL HEADERS ---------- */ HTTPc_ReqSetParam(p_req, HTTPc_PARAM_TYPE_REQ_HDR_HOOK, &HTTPcApp_ReqHdrHook, &err); if (err != HTTPc_ERR_NONE) { return (DEF_FAIL); } /* ------------ SET REQ/RESP HOOK FUNCTIONS ----------- */ HTTPc_ReqSetParam(p_req, HTTPc_PARAM_TYPE_RESP_HDR_HOOK, &HTTPcApp_RespHdrHook, &err); if (err != HTTPc_ERR_NONE) { return (DEF_FAIL); } HTTPc_ReqSetParam(p_req, HTTPc_PARAM_TYPE_RESP_BODY_HOOK, &HTTPcApp_RespBodyHook, &err); if (err != HTTPc_ERR_NONE) { return (DEF_FAIL); } /* --------- SET REQ/RESP CALLBACK FUNCTIONS ---------- */ #if (HTTPc_CFG_MODE_ASYNC_TASK_EN == DEF_ENABLED) HTTPc_ReqSetParam(p_req, HTTPc_PARAM_TYPE_TRANS_COMPLETE_CALLBACK, &HTTPcApp_TransDoneCallback, &err); if (err != HTTPc_ERR_NONE) { return (DEF_FAIL); } HTTPc_ReqSetParam(p_req, HTTPc_PARAM_TYPE_TRANS_ERR_CALLBACK, &HTTPcApp_TransErrCallback, &err); if (err != HTTPc_ERR_NONE) { return (DEF_FAIL); } #endif return (DEF_OK); }
Related content
HTTPc_ReqSetParam
HTTPc_ReqSetParam
More like this
On Request Header
On Request Header
More like this
On Request Body
On Request Body
More like this
Request's Body Standard Transfer
Request's Body Standard Transfer
More like this
HTTPc API
HTTPc API
More like this
HTTPc_ReqSend
HTTPc_ReqSend
More like this