Initialize the request headers, stored in HTTPRequestHeaders_t.pBuffer, with initial configurations from HTTPRequestInfo_t. This method is expected to be called before sending a new request.
HTTPStatus_t HTTPClient_InitializeRequestHeaders(HTTPRequestHeaders_t *pRequestHeaders, const HTTPRequestInfo_t *pRequestInfo)
Initialize the request headers, stored in HTTPRequestHeaders_t.pBuffer, with initial configurations f...
Definition: core_http_client.c:1567
HTTPStatus_t
The HTTP Client library return status.
Definition: core_http_client.h:164
Configurations of the initial request headers.
Definition: core_http_client.h:353
Upon return, HTTPRequestHeaders_t.headersLen will be updated with the number of bytes written.
Each line in the header is listed below and written in this order: <HTTPRequestInfo_t.pMethod> <HTTPRequestInfo_t.pPath> <HTTP_PROTOCOL_VERSION> User-Agent: <HTTP_USER_AGENT_VALUE> Host: <HTTPRequestInfo_t.pHost>
Note that "Connection" header can be added and set to "keep-alive" by activating the HTTP_REQUEST_KEEP_ALIVE_FLAG in HTTPRequestInfo_t.reqFlags.
- Parameters
-
[in] | pRequestHeaders | Request header buffer information. |
[in] | pRequestInfo | Initial request header configurations. |
- Returns
- One of the following:
Example
uint8_t requestHeaderBuffer[ 256 ] = { 0 };
requestHeaders.
pBuffer = requestHeaderBuffer;
requestInfo.
pPath =
"/html/rfc2616"
requestInfo.
pathLen =
sizeof(
"/html/rfc2616" ) - 1U;
requestInfo.
pHost =
"tools.ietf.org"
requestInfo.
hostLen =
sizeof(
"tools.ietf.org" ) - 1U;
&requestInfo );
#define HTTP_METHOD_GET
Definition: core_http_client.h:62
@ HTTPSuccess
The HTTP Client library function completed successfully.
Definition: core_http_client.h:175
#define HTTP_REQUEST_KEEP_ALIVE_FLAG
Set this flag to indicate that the request is for a persistent connection.
Definition: core_http_client.h:114
uint32_t reqFlags
Flags to activate other request header configurations.
Definition: core_http_client.h:379
size_t methodLen
Definition: core_http_client.h:358
const char * pMethod
The HTTP request method e.g. "GET", "POST", "PUT", or "HEAD".
Definition: core_http_client.h:357
const char * pPath
The Request-URI to the objects of interest, e.g. "/path/to/item.txt".
Definition: core_http_client.h:363
const char * pHost
The server's host name, e.g. "my-storage.my-cloud.com".
Definition: core_http_client.h:371
size_t pathLen
Definition: core_http_client.h:364
size_t hostLen
Definition: core_http_client.h:372