µC/HTTP-client supports the addition of header fields to an HTTP request:
- The preprocessor macro
HTTPc_CFG_HDR_TX_EN
must be set toDEF_ENABLED
. HTTPc_HDR
objects must be used to set up headed fields to add.- Two methods are offered by the µC/HTTP-client stack to add header fields:
- Passing a header fields table to to the µC/HTTP-client stack
- Using a hook function that will ask the application for each header field to add to the request.
- The preprocessor macro
Some header fields are taken care of by the µC/HTTP-client stack and must therefore not be added by the application :
- Host
- Content-Type
- Content-Length
- Transfer-Encoding
- Connection
Using a Header Fields Table
With the first option, before sending the HTTP request, the application can prepare a table of HTTPc_HDR
objects that the µC/HTTP-client will include in the request. The API function HTTPc_ReqSetParam must be used with the parameter type HTTPc_PARAM_TYPE_REQ_HDR_TBL to pass out the table to the µC/HTTP-client stack.
Using a Hook Function
The Second option is to set up a hook function. The hook function will be called by the µC/HTTP-client core to add a Header Field to the request. The hook function will be called until it return DEF_YES
to notified the µC/HTTP-client stack that all the fields have been added. The API function HTTPc_ReqSetParam must be used with the parameter type HTTPc_PARAM_TYPE_REQ_HDR_HOOK to pass out hook function pointer to the µC/HTTP-client stack.