FreeRTOS: HTTPS Client
HTTPS Client v1.0.0 library
Return to main page ↑
IotHttpsClient_ReadHeader

Retrieve the header of interest from the response represented by respHandle.

char * pName,
uint32_t nameLen,
char * pValue,
uint32_t valueLen );

The response headers as received from the network will be stored in the header buffer space in IotHttpsResponseInfo_t.userBuffer. If the configured IotHttpsResponseInfo_t.userBuffer is too small to fit the headers received, then headers that don't fit will be thrown away. Please see responseUserBufferMinimumSize for information about sizing the IotHttpsResponseInfo_t.userBuffer.

This routine parses the formatted HTTPS header lines in the header buffer for the header field name specified. If the header is not available, then IOT_HTTPS_NOT_FOUND is returned.

For an asynchronous response, this routine is to be called during the IotHttpsClientCallbacks_t.readReadyCallback. Before the IotHttpsClientCallbacks_t.readReadyCallback is invoked, the headers are read into as much as can fit in in the header buffer space of IotHttpsResponseInfo_t.userBuffer. Example Asynchronous Code

void applicationDefined_readReadyCallback(void * pPrivData, IotHttpsResponseHandle_t respHandle, IotHttpsReturnCode_t rc, uint16_t status)
{
...
char valueBuf[64];
const char contentTypeName[] = "Content-Type";
uint32_t contentTypeNmeLength = strlen(contentTypeName);
IotHttpsClient_ReadHeader(respHandle, contentTypeName, contentTypeNameLength, valueBuf, sizeof(valueBuf));
...
}

For a syncrhonous response, this routine is to be called after IotHttpsClient_SendSync has returned successfully. Example Synchronous Code

...
IotHttpsClient_SendSync(&connHandle, reqHandle, &respHandle, &respInfo, timeout);
char valueBuf[10];
const char contentTypeName[] = "Content-Type";
uint32_t contentTypeNmeLength = strlen(contentTypeName);
IotHttpsClient_ReadHeader(respHandle, contentTypeName, contentTypeNmeLength, valueBuf, sizeof(valueBuf));
uint32_t length = strtoul(valueBuf, NULL, 10);
...
Parameters
[in]respHandle- Unique handle representing the HTTPS response.
[in]pName- HTTPS Header field name we want the value of. This must be NULL terminated.
[in]nameLen- The length of the name string.
[out]pValue- Buffer to hold the HTTPS field's value. The returned value will be NULL terminated and therfore the buffer must be large enough to hold the terminating NULL character.
[in]valueLen- The length of the value buffer.
Returns
One of the following:
IotHttpsResponseHandle_t
struct _httpsResponse * IotHttpsResponseHandle_t
Opaque handle of an HTTP response.
Definition: iot_https_types.h:280
IotHttpsClient_ReadHeader
IotHttpsReturnCode_t IotHttpsClient_ReadHeader(IotHttpsResponseHandle_t respHandle, char *pName, uint32_t nameLen, char *pValue, uint32_t valueLen)
Retrieve the header of interest from the response represented by respHandle.
Definition: iot_https_client.c:3264
IotHttpsReturnCode_t
IotHttpsReturnCode_t
Return codes of HTTPS Client functions.
Definition: iot_https_types.h:294