Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

The HTTPc Response object will be filled by the µC/HTTP-client stack with the below fields received in the HTTP response:

  • The Server HTTP version
  • Status Code
  • Reason phrase
  • Content type (if body present)
  • Content Length (if body present)

If the function HTTPc_ReqSend was called in the blocking mode and the function returned with no errors, then the HTTPc Response object can be read by the application after the function call. Otherwise, the application must way until the On Transaction Complete function is called by the µC/HTTP-client stack to read the HTTPc Response object.

Two hook functions allow the application to retrieve more data from the HTTP response :

The first hook allows the application to retrieve header fields contained in the HTTP response. If the hook function is set via the function HTTPc_ReqSetParam with the parameter type HTTPc_PARAM_TYPE_RESP_HDR_HOOK, the hook will be called by the µC/HTTP-client stack for each header field parsed and recognized by the stack. The application as therefore the liberty to copy the data received on its side inside the hook function.

The second hook allows the application to retrieve the data contained in the HTTP response body. If the hook function is set via the function HTTPc_ReqSetParam with the parameter type HTTPc_PARAM_TYPE_RESP_BODY_HOOK, the hook will be called by the µC/HTTP-client stack for each piece of data received until all is received.

Examples

Blocking Mode

In the first example below, the function HTTPc_ReqSend is called in the blocking mode. Therefore, the HTTPc Response object can be read just after the function call.

No-Blocking Mode

In this second example, the function HTTPc_ReqSend is called in the no-blocking mode. Therefore, the HTTPc Response object can be read once the On Transaction Complete function was called.

Response Header and Body Hook Funcitons

The example code below is an implementation of the On Response Header hook function and the On Response Body hook function.

  • No labels