Initializes the request by adding a formatted Request-Line to the start of HTTPS request header buffer.
This function will initialize the HTTP request context by setting where to write the next headers to the start of the configured header buffer in IotHttpsRequestInfo_t.userBuffer.
The Request-Line will be added to the start of the headers space in IotHttpsRequestInfo_t.userBuffer. The header space follows the request context in the user buffer. See requestUserBufferMinimumSize for more information on sizing the IotHttpsRequestInfo_t.userBuffer so that this function does not fail.
The Request-Line generated is of the following format:
Example:
GET /path/to/item.file?possible_query HTTP/1.1\r\n
The initial required headers are also added to the IotHttpsRequestInfo_t.userBuffer. These headers are User-Agent and Host. The User-Agent value is configured in iot_config.h using IOT_HTTPS_USER_AGENT. The Host value is the DNS resolvable server address.
- Parameters
-
[out] | pReqHandle | - request handle representing the internal request context is returned. NULL if the function failed. |
[in] | pReqInfo | - HTTPS request information. |
- Returns
- One of the following:
Example
uint8_t* pRequestUserBuffer = (uint8_t*)malloc(userBufferSize);
syncInfo.
pBody = PREDEFINED_BODY_BUFFER;
syncInfo.
bodyLen = PREDEFINED_BODY_BUFFER_LEN;
reqInfo.
pPath =
"/path_to_item?query_maybe";
reqInfo.pPathLen = strlen("/path_to_item?query_maybe");
reqInfo.
method = IOT_HTTPS_METHOD_GET;
reqInfo.
pHost =
"www.amazon.com";
reqInfo.
hostLen = strlen(
"www.amazon.com");
{
}
uint8_t * pBody
Definition: iot_https_types.h:681
const char * pHost
Host address this request is intended for, e.g., "awsamazon.com".
Definition: iot_https_types.h:826
uint8_t * pBuffer
Application provided buffer pointer.
Definition: iot_https_types.h:651
IotHttpsUserBuffer_t userBuffer
Application owned buffer for storing the request headers and internal request context.
Definition: iot_https_types.h:852
uint32_t bufferLen
The length of the application provided buffer.
Definition: iot_https_types.h:652
#define IOT_HTTPS_SYNC_INFO_INITIALIZER
Initializer for IotHttpsSyncInfo_t.
Definition: iot_https_types.h:198
uint32_t bodyLen
The length of the HTTP message body.
Definition: iot_https_types.h:682
uint32_t hostLen
Host address length.
Definition: iot_https_types.h:827
HTTP request configuration.
Definition: iot_https_types.h:796
struct _httpsRequest * IotHttpsRequestHandle_t
Opaque handle of an HTTP request.
Definition: iot_https_types.h:263
HTTPS Client synchronous request information.
Definition: iot_https_types.h:668
IotHttpsReturnCode_t IotHttpsClient_InitializeRequest(IotHttpsRequestHandle_t *pReqHandle, IotHttpsRequestInfo_t *pReqInfo)
Initializes the request by adding a formatted Request-Line to the start of HTTPS request header buffe...
Definition: iot_https_client.c:2731
IotHttpsMethod_t method
On of the HTTP method tokens defined in IotHttpsMethod_t.
Definition: iot_https_types.h:817
#define IOT_HTTPS_REQUEST_INFO_INITIALIZER
Initializer for IotHttpsRequestInfo_t.
Definition: iot_https_types.h:204
bool isAsync
Indicator if this request is sync or async.
Definition: iot_https_types.h:859
const uint32_t requestUserBufferMinimumSize
The minimum user buffer size for the HTTP request context and headers.
Definition: iot_https_client.c:118
@ IOT_HTTPS_OK
Returned for a successful operation.
Definition: iot_https_types.h:298
#define IOT_HTTPS_REQUEST_HANDLE_INITIALIZER
Initializer for IotHttpsRequestHandle_t.
Definition: iot_https_types.h:192
IotHttpsReturnCode_t
Return codes of HTTPS Client functions.
Definition: iot_https_types.h:294
const char * pPath
The absolute path to the HTTP request object.
Definition: iot_https_types.h:808
bool isNonPersistent
Flag denoting if the connection should be non-persistent.
Definition: iot_https_types.h:842
IotHttpsSyncInfo_t * pSyncInfo
Information specifically for synchronous requests.
Definition: iot_https_types.h:870