On Response Header
Called by the µC/HTTP-client core for each header field received in the HTTP response and recognize by the µC/HTTP-client stack.
The application can decide to copy the header received or to ignore the header in the hook function. The parameter HTTPc_PARAM_TYPE_RESP_HDR_HOOK
must be set up using the function HTTPc_ReqSetParam()
for the hook function to be called.
Prototype
void HTTPc_RespHdrHook (HTTPc_CONN_OBJ *p_conn_obj, HTTPc_REQ_OBJ *p_req_obj, HTTP_HDR_FIELD hdr_field, CPU_CHAR *p_hdr_val, CPU_INT16U val_len);
Arguments
p_conn_obj
Pointer to the current HTTPc Connection Object.
p_req_obj
Pointer to the current HTTPc Request Object.
hdr_field
HTTP header type of the header field received in the HTTP response.
p_hdr_val
Pointer to the value string received in the Response header field.
val_len
Length of the value string.
Return Values
None.
Required Configuration
- The
HTTPc_CFG_HDR_RX_EN
configuration macro MUST be enabled.
Notes / Warnings
None.
Example Template
Listing - Response Header Callback Function Example Code
HTTPc_HDR AppHTTPc_RespHdr; CPU_CHAR AppHTTPc_RespHdrValBuf[100]; static void HTTPc_RespHdrHook (HTTPc_CONN_OBJ *p_conn, HTTPc_REQ_OBJ *p_req, HTTP_HDR_FIELD hdr_field, CPU_CHAR *p_hdr_val, CPU_INT16U val_len) { HTTPc_HDR *p_hdr; p_hdr = &AppHTTPc_RespHdr; p_hdr->ValPtr = &AppHTTPc_RespHdrValBuf; switch (hdr_field) { case HTTP_HDR_FIELD_COOKIE: p_hdr->HdrField = hdr_field; Str_Copy_N(p_hdr->ValPtr, p_hdr_val, val_len); p_hdr->ValLen = val_len; break; default: break; } }