coreHTTP  v2.0.0
HTTP/1.1 Client Library

Send the request headers in HTTPRequestHeaders_t.pBuffer and request body in pRequestBodyBuf over the transport. The response is received in HTTPResponse_t.pBuffer.

HTTPRequestHeaders_t * pRequestHeaders,
const uint8_t * pRequestBodyBuf,
size_t reqBodyBufLen,
HTTPResponse_t * pResponse,
uint32_t sendFlags );

If HTTP_SEND_DISABLE_CONTENT_LENGTH_FLAG is not set in parameter sendFlags, then the Content-Length to be sent to the server is automatically written to pRequestHeaders. The Content-Length will not be written when there is no request body. If there is not enough room in the buffer to write the Content-Length then HTTPInsufficientMemory is returned. Please see HTTP_MAX_CONTENT_LENGTH_HEADER_LENGTH for the maximum Content-Length header field and value that could be written to the buffer.

The application should close the connection with the server if any of the following errors are returned:

The pResponse returned is valid only if this function returns HTTPSuccess.

[in]pTransportTransport interface, see TransportInterface_t for more information.
[in]pRequestHeadersRequest configuration containing the buffer of headers to send.
[in]pRequestBodyBufOptional Request entity body. Set to NULL if there is no request body.
[in]reqBodyBufLenThe length of the request entity in bytes.
[in]pResponseThe response message and some notable response parameters will be returned here on success.
[in]sendFlagsFlags which modify the behavior of this function. Please see HTTPClient_Send Flags for more information.
One of the following:


// Variables used in this example.
HTTPStatus_t httpLibraryStatus = HTTPSuccess;
TransportInterface_t transportInterface = { 0 };
char requestBody[] = "This is an example request body.";
// Assume that requestHeaders has been initialized with
// HTTPClient_InitializeResponseHeaders() and any additional headers have
// been added with HTTPClient_AddHeader().
HTTPRequestHeaders_t requestHeaders;
// Set the transport interface with platform specific functions that are
// assumed to be implemented elsewhere.
transportInterface.recv = myPlatformTransportReceive;
transportInterface.send = myPlatformTransportSend;
transportInterface.pNetworkContext = myPlatformNetworkContext;
// Set the buffer to receive the HTTP response message into. The buffer is
// dynamically allocated for demonstration purposes only.
response.pBuffer = ( uint8_t* )malloc( 1024 );
response.bufferLen = 1024;
httpLibraryStatus = HTTPClient_Send( &transportInterface,
sizeof( requestBody ) - 1U,
0 );
if( httpLibraryStatus == HTTPSuccess )
if( response.status == 200 )
// Handle a response Status-Code of 200 OK.
@ HTTPSuccess
The HTTP Client library function completed successfully.
Definition: core_http_client.h:167
Represents header data that will be sent in an HTTP request.
Definition: core_http_client.h:323
TransportSend_t send
Definition: transport_interface.h:248
Represents an HTTP response.
Definition: core_http_client.h:428
The HTTP Client library return status.
Definition: core_http_client.h:156
HTTPStatus_t HTTPClient_Send(const TransportInterface_t *pTransport, HTTPRequestHeaders_t *pRequestHeaders, const uint8_t *pRequestBodyBuf, size_t reqBodyBufLen, HTTPResponse_t *pResponse, uint32_t sendFlags)
Send the request headers in HTTPRequestHeaders_t.pBuffer and request body in pRequestBodyBuf over the...
Definition: core_http_client.c:2118
NetworkContext_t * pNetworkContext
Definition: transport_interface.h:249
TransportRecv_t recv
Definition: transport_interface.h:247
The transport layer interface.
Definition: transport_interface.h:246