From 7011be295a9eef54750fedec6f4f48e36fa94b30 Mon Sep 17 00:00:00 2001 From: cryi Date: Wed, 25 Oct 2023 21:09:28 +0200 Subject: [PATCH 1/5] expose internals --- source/core_http_client.c | 24 ++++++++++++++++++++++++ source/include/core_http_client.h | 13 +++++++++++++ 2 files changed, 37 insertions(+) diff --git a/source/core_http_client.c b/source/core_http_client.c index 2ea4d04d..07267e25 100644 --- a/source/core_http_client.c +++ b/source/core_http_client.c @@ -1941,6 +1941,15 @@ static HTTPStatus_t sendHttpHeaders( const TransportInterface_t * pTransport, return returnStatus; } +HTTPStatus_t HTTPClient_InternalSendHttpHeaders( const TransportInterface_t* pTransport, + HTTPClient_GetCurrentTimeFunc_t getTimestampMs, + HTTPRequestHeaders_t* pRequestHeaders, + size_t reqBodyLen, + uint32_t sendFlags) +{ + return sendHttpHeaders(pTransport, getTimestampMs, pRequestHeaders, reqBodyLen, sendFlags); +} + /*-----------------------------------------------------------*/ static HTTPStatus_t sendHttpBody( const TransportInterface_t * pTransport, @@ -1962,6 +1971,14 @@ static HTTPStatus_t sendHttpBody( const TransportInterface_t * pTransport, return returnStatus; } +HTTPStatus_t HTTPClient_InternalSendHttpData( const TransportInterface_t* pTransport, + HTTPClient_GetCurrentTimeFunc_t getTimestampMs, + const uint8_t* pData, + size_t dataLen) +{ + return sendHttpData(pTransport, getTimestampMs, pData, dataLen); +} + /*-----------------------------------------------------------*/ static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState, @@ -2128,6 +2145,13 @@ static HTTPStatus_t receiveAndParseHttpResponse( const TransportInterface_t * pT return returnStatus; } +HTTPStatus_t HTTPClient_InternalReceiveAndParseHttpResponse( const TransportInterface_t* pTransport, + HTTPResponse_t* pResponse, + const HTTPRequestHeaders_t* pRequestHeaders) +{ + return receiveAndParseHttpResponse(pTransport, pResponse, pRequestHeaders); +} + /*-----------------------------------------------------------*/ static HTTPStatus_t sendHttpRequest( const TransportInterface_t * pTransport, diff --git a/source/include/core_http_client.h b/source/include/core_http_client.h index 3425f7e0..f002969b 100644 --- a/source/include/core_http_client.h +++ b/source/include/core_http_client.h @@ -821,6 +821,19 @@ HTTPStatus_t HTTPClient_Send( const TransportInterface_t * pTransport, uint32_t sendFlags ); /* @[declare_httpclient_send] */ +HTTPStatus_t HTTPClient_InternalReceiveAndParseHttpResponse( const TransportInterface_t* pTransport,^M + HTTPResponse_t* pResponse,^M + const HTTPRequestHeaders_t* pRequestHeaders); + +HTTPStatus_t HTTPClient_InternalSendHttpHeaders( const TransportInterface_t* pTransport, + HTTPClient_GetCurrentTimeFunc_t getTimestampMs, + HTTPRequestHeaders_t* pRequestHeaders, size_t reqBodyLen, + uint32_t sendFlags); + +HTTPStatus_t HTTPClient_InternalSendHttpData( const TransportInterface_t* pTransport, + HTTPClient_GetCurrentTimeFunc_t getTimestampMs, const uint8_t* pData, + size_t dataLen); + /** * @brief Read a header from a buffer containing a complete HTTP response. * This will return the location of the response header value in the From 3438a0954fddd6c10c1f68a2af7545efc5ca4b8b Mon Sep 17 00:00:00 2001 From: V <36897290+cryi@users.noreply.github.com> Date: Sat, 4 Nov 2023 15:16:45 +0100 Subject: [PATCH 2/5] Headers complete (#1) exposed internal function, added areHeadersComplete --- docs/doxygen/include/size_table.md | 4 +- source/core_http_client.c | 118 ++++++++++++----------------- source/include/core_http_client.h | 52 +++++++++---- 3 files changed, 91 insertions(+), 83 deletions(-) diff --git a/docs/doxygen/include/size_table.md b/docs/doxygen/include/size_table.md index 64dccdd3..fed45453 100644 --- a/docs/doxygen/include/size_table.md +++ b/docs/doxygen/include/size_table.md @@ -9,7 +9,7 @@ core_http_client.c -
3.1K
+
3.2K
2.5K
@@ -29,7 +29,7 @@ Total estimates -
23.9K
+
24.0K
20.7K
diff --git a/source/core_http_client.c b/source/core_http_client.c index 07267e25..80cec2fd 100644 --- a/source/core_http_client.c +++ b/source/core_http_client.c @@ -55,10 +55,10 @@ static uint32_t getZeroTimestampMs( void ); * bytes than what were specified were sent, then #HTTPNetworkError is * returned. */ -static HTTPStatus_t sendHttpData( const TransportInterface_t * pTransport, - HTTPClient_GetCurrentTimeFunc_t getTimestampMs, - const uint8_t * pData, - size_t dataLen ); +HTTPStatus_t HTTPClient_SendHttpData( const TransportInterface_t * pTransport, + HTTPClient_GetCurrentTimeFunc_t getTimestampMs, + const uint8_t * pData, + size_t dataLen ); /** * @brief Send the HTTP headers over the transport send interface. @@ -75,11 +75,11 @@ static HTTPStatus_t sendHttpData( const TransportInterface_t * pTransport, * bytes than what were specified were sent, then #HTTPNetworkError is * returned. */ -static HTTPStatus_t sendHttpHeaders( const TransportInterface_t * pTransport, - HTTPClient_GetCurrentTimeFunc_t getTimestampMs, - HTTPRequestHeaders_t * pRequestHeaders, - size_t reqBodyLen, - uint32_t sendFlags ); +HTTPStatus_t HTTPClient_SendHttpHeaders( const TransportInterface_t * pTransport, + HTTPClient_GetCurrentTimeFunc_t getTimestampMs, + HTTPRequestHeaders_t * pRequestHeaders, + size_t reqBodyLen, + uint32_t sendFlags ); /** * @brief Adds the Content-Length header field and value to the @@ -198,9 +198,9 @@ static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState, * receive error. Please see #parseHttpResponse and #getFinalResponseStatus for * other statuses returned. */ -static HTTPStatus_t receiveAndParseHttpResponse( const TransportInterface_t * pTransport, - HTTPResponse_t * pResponse, - const HTTPRequestHeaders_t * pRequestHeaders ); +HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse( const TransportInterface_t * pTransport, + HTTPResponse_t * pResponse, + const HTTPRequestHeaders_t * pRequestHeaders ); /** * @brief Send the HTTP request over the network. @@ -212,7 +212,7 @@ static HTTPStatus_t receiveAndParseHttpResponse( const TransportInterface_t * pT * @param[in] reqBodyBufLen Length of the request body buffer. * @param[in] sendFlags Application provided flags to #HTTPClient_Send. * - * @return Returns #HTTPSuccess if successful. Please see #sendHttpHeaders and + * @return Returns #HTTPSuccess if successful. Please see #HTTPClient_SendHttpHeaders and * #sendHttpBody for other statuses returned. */ static HTTPStatus_t sendHttpRequest( const TransportInterface_t * pTransport, @@ -833,6 +833,9 @@ static int httpParserOnHeadersCompleteCallback( llhttp_t * pHttpParser ) assert( pResponse != NULL ); assert( pParsingContext->pBufferCur != NULL ); + /* Flag indicating that the headers have been completely signed - useful for libraries built on top of corehttp. */ + pResponse->areHeadersComplete = 1; + /* The current location to parse was updated in previous callbacks and MUST * always be within the response buffer. */ assert( pParsingContext->pBufferCur >= ( const char * ) ( pResponse->pBuffer ) ); @@ -1632,12 +1635,15 @@ HTTPStatus_t HTTPClient_InitializeRequestHeaders( HTTPRequestHeaders_t * pReques if( returnStatus == HTTPSuccess ) { - /* Write "User-Agent: ". */ - returnStatus = addHeader( pRequestHeaders, - HTTP_USER_AGENT_FIELD, - HTTP_USER_AGENT_FIELD_LEN, - HTTP_USER_AGENT_VALUE, - HTTP_USER_AGENT_VALUE_LEN ); + if( ( HTTP_REQUEST_NO_USER_AGENT_FLAG & pRequestInfo->reqFlags ) == 0U ) + { + /* Write "User-Agent: ". */ + returnStatus = addHeader( pRequestHeaders, + HTTP_USER_AGENT_FIELD, + HTTP_USER_AGENT_FIELD_LEN, + HTTP_USER_AGENT_VALUE, + HTTP_USER_AGENT_VALUE_LEN ); + } } if( returnStatus == HTTPSuccess ) @@ -1793,10 +1799,10 @@ HTTPStatus_t HTTPClient_AddRangeHeader( HTTPRequestHeaders_t * pRequestHeaders, /*-----------------------------------------------------------*/ -static HTTPStatus_t sendHttpData( const TransportInterface_t * pTransport, - HTTPClient_GetCurrentTimeFunc_t getTimestampMs, - const uint8_t * pData, - size_t dataLen ) +HTTPStatus_t HTTPClient_SendHttpData( const TransportInterface_t * pTransport, + HTTPClient_GetCurrentTimeFunc_t getTimestampMs, + const uint8_t * pData, + size_t dataLen ) { HTTPStatus_t returnStatus = HTTPSuccess; const uint8_t * pIndex = pData; @@ -1905,11 +1911,11 @@ static HTTPStatus_t addContentLengthHeader( HTTPRequestHeaders_t * pRequestHeade /*-----------------------------------------------------------*/ -static HTTPStatus_t sendHttpHeaders( const TransportInterface_t * pTransport, - HTTPClient_GetCurrentTimeFunc_t getTimestampMs, - HTTPRequestHeaders_t * pRequestHeaders, - size_t reqBodyLen, - uint32_t sendFlags ) +HTTPStatus_t HTTPClient_SendHttpHeaders( const TransportInterface_t * pTransport, + HTTPClient_GetCurrentTimeFunc_t getTimestampMs, + HTTPRequestHeaders_t * pRequestHeaders, + size_t reqBodyLen, + uint32_t sendFlags ) { HTTPStatus_t returnStatus = HTTPSuccess; uint8_t shouldSendContentLength = 0U; @@ -1932,24 +1938,15 @@ static HTTPStatus_t sendHttpHeaders( const TransportInterface_t * pTransport, { LogDebug( ( "Sending HTTP request headers: HeaderBytes=%lu", ( unsigned long ) ( pRequestHeaders->headersLen ) ) ); - returnStatus = sendHttpData( pTransport, - getTimestampMs, - pRequestHeaders->pBuffer, - pRequestHeaders->headersLen ); + returnStatus = HTTPClient_SendHttpData( pTransport, + getTimestampMs, + pRequestHeaders->pBuffer, + pRequestHeaders->headersLen ); } return returnStatus; } -HTTPStatus_t HTTPClient_InternalSendHttpHeaders( const TransportInterface_t* pTransport, - HTTPClient_GetCurrentTimeFunc_t getTimestampMs, - HTTPRequestHeaders_t* pRequestHeaders, - size_t reqBodyLen, - uint32_t sendFlags) -{ - return sendHttpHeaders(pTransport, getTimestampMs, pRequestHeaders, reqBodyLen, sendFlags); -} - /*-----------------------------------------------------------*/ static HTTPStatus_t sendHttpBody( const TransportInterface_t * pTransport, @@ -1966,19 +1963,11 @@ static HTTPStatus_t sendHttpBody( const TransportInterface_t * pTransport, /* Send the request body. */ LogDebug( ( "Sending the HTTP request body: BodyBytes=%lu", ( unsigned long ) reqBodyBufLen ) ); - returnStatus = sendHttpData( pTransport, getTimestampMs, pRequestBodyBuf, reqBodyBufLen ); + returnStatus = HTTPClient_SendHttpData( pTransport, getTimestampMs, pRequestBodyBuf, reqBodyBufLen ); return returnStatus; } -HTTPStatus_t HTTPClient_InternalSendHttpData( const TransportInterface_t* pTransport, - HTTPClient_GetCurrentTimeFunc_t getTimestampMs, - const uint8_t* pData, - size_t dataLen) -{ - return sendHttpData(pTransport, getTimestampMs, pData, dataLen); -} - /*-----------------------------------------------------------*/ static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState, @@ -2028,9 +2017,9 @@ static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState, /*-----------------------------------------------------------*/ -static HTTPStatus_t receiveAndParseHttpResponse( const TransportInterface_t * pTransport, - HTTPResponse_t * pResponse, - const HTTPRequestHeaders_t * pRequestHeaders ) +HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse( const TransportInterface_t * pTransport, + HTTPResponse_t * pResponse, + const HTTPRequestHeaders_t * pRequestHeaders ) { HTTPStatus_t returnStatus = HTTPSuccess; size_t totalReceived = 0U; @@ -2145,13 +2134,6 @@ static HTTPStatus_t receiveAndParseHttpResponse( const TransportInterface_t * pT return returnStatus; } -HTTPStatus_t HTTPClient_InternalReceiveAndParseHttpResponse( const TransportInterface_t* pTransport, - HTTPResponse_t* pResponse, - const HTTPRequestHeaders_t* pRequestHeaders) -{ - return receiveAndParseHttpResponse(pTransport, pResponse, pRequestHeaders); -} - /*-----------------------------------------------------------*/ static HTTPStatus_t sendHttpRequest( const TransportInterface_t * pTransport, @@ -2170,11 +2152,11 @@ static HTTPStatus_t sendHttpRequest( const TransportInterface_t * pTransport, assert( getTimestampMs != NULL ); /* Send the headers, which are at one location in memory. */ - returnStatus = sendHttpHeaders( pTransport, - getTimestampMs, - pRequestHeaders, - reqBodyBufLen, - sendFlags ); + returnStatus = HTTPClient_SendHttpHeaders( pTransport, + getTimestampMs, + pRequestHeaders, + reqBodyBufLen, + sendFlags ); /* Send the body, which is at another location in memory. */ if( returnStatus == HTTPSuccess ) @@ -2290,9 +2272,9 @@ HTTPStatus_t HTTPClient_Send( const TransportInterface_t * pTransport, if( returnStatus == HTTPSuccess ) { - returnStatus = receiveAndParseHttpResponse( pTransport, - pResponse, - pRequestHeaders ); + returnStatus = HTTPClient_ReceiveAndParseHttpResponse( pTransport, + pResponse, + pRequestHeaders ); } return returnStatus; diff --git a/source/include/core_http_client.h b/source/include/core_http_client.h index f002969b..70fe835b 100644 --- a/source/include/core_http_client.h +++ b/source/include/core_http_client.h @@ -111,7 +111,18 @@ * * This flag is valid only for #HTTPRequestInfo_t reqFlags parameter. */ -#define HTTP_REQUEST_KEEP_ALIVE_FLAG 0x1U +#define HTTP_REQUEST_KEEP_ALIVE_FLAG 0x1U + +/** + * @ingroup http_request_flags + * @brief Set this flag to skip the User-Agent in the request headers. + * + * Setting this will cause the "User-Agent: " to be omitted in the + * request headers. + * + * This flag is valid only for #HTTPRequestInfo_t reqFlags parameter. + */ +#define HTTP_REQUEST_NO_USER_AGENT_FLAG 0x2U /** * @defgroup http_response_flags HTTPResponse_t Flags @@ -517,6 +528,13 @@ typedef struct HTTPResponse */ size_t headerCount; + /** + * @brief Indicates whether the HTTP response headers have been fully received. + * + * This variable is set to 1 after all headers have been received and processed by #HTTPClient_Send. + */ + uint8_t areHeadersComplete; + /** * @brief Flags of useful headers found in the response. * @@ -719,6 +737,21 @@ HTTPStatus_t HTTPClient_AddRangeHeader( HTTPRequestHeaders_t * pRequestHeaders, int32_t rangeEnd ); /* @[declare_httpclient_addrangeheader] */ +/* @[declare_httpclient_sendhttpheaders] */ +HTTPStatus_t HTTPClient_SendHttpHeaders( const TransportInterface_t * pTransport, + HTTPClient_GetCurrentTimeFunc_t getTimestampMs, + HTTPRequestHeaders_t * pRequestHeaders, + size_t reqBodyLen, + uint32_t sendFlags ); +/* @[declare_httpclient_sendhttpheaders] */ + +/* @[declare_httpclient_sendhttpdata] */ +HTTPStatus_t HTTPClient_SendHttpData( const TransportInterface_t * pTransport, + HTTPClient_GetCurrentTimeFunc_t getTimestampMs, + const uint8_t * pData, + size_t dataLen ); +/* @[declare_httpclient_sendhttpdata] */ + /** * @brief Send the request headers in #HTTPRequestHeaders_t.pBuffer and request * body in @p pRequestBodyBuf over the transport. The response is received in @@ -821,18 +854,11 @@ HTTPStatus_t HTTPClient_Send( const TransportInterface_t * pTransport, uint32_t sendFlags ); /* @[declare_httpclient_send] */ -HTTPStatus_t HTTPClient_InternalReceiveAndParseHttpResponse( const TransportInterface_t* pTransport,^M - HTTPResponse_t* pResponse,^M - const HTTPRequestHeaders_t* pRequestHeaders); - -HTTPStatus_t HTTPClient_InternalSendHttpHeaders( const TransportInterface_t* pTransport, - HTTPClient_GetCurrentTimeFunc_t getTimestampMs, - HTTPRequestHeaders_t* pRequestHeaders, size_t reqBodyLen, - uint32_t sendFlags); - -HTTPStatus_t HTTPClient_InternalSendHttpData( const TransportInterface_t* pTransport, - HTTPClient_GetCurrentTimeFunc_t getTimestampMs, const uint8_t* pData, - size_t dataLen); +/* @[declare_httpclient_receiveandparsehttpresponse] */ +HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse( const TransportInterface_t * pTransport, + HTTPResponse_t * pResponse, + const HTTPRequestHeaders_t * pRequestHeaders ); +/* @[declare_httpclient_receiveandparsehttpresponse] */ /** * @brief Read a header from a buffer containing a complete HTTP response. From 17e64180b330fccaecff193a432b69be91851d09 Mon Sep 17 00:00:00 2001 From: Eric Jackson Date: Mon, 6 Nov 2023 17:34:48 -0800 Subject: [PATCH 3/5] Adds documentation --- source/core_http_client.c | 41 ++------------------ source/include/core_http_client.h | 63 +++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 38 deletions(-) diff --git a/source/core_http_client.c b/source/core_http_client.c index 80cec2fd..995143ff 100644 --- a/source/core_http_client.c +++ b/source/core_http_client.c @@ -43,38 +43,13 @@ */ static uint32_t getZeroTimestampMs( void ); -/** - * @brief Send HTTP bytes over the transport send interface. - * - * @param[in] pTransport Transport interface. - * @param[in] getTimestampMs Function to retrieve a timestamp in milliseconds. - * @param[in] pData HTTP request data to send. - * @param[in] dataLen HTTP request data length. - * - * @return #HTTPSuccess if successful. If there was a network error or less - * bytes than what were specified were sent, then #HTTPNetworkError is - * returned. - */ + HTTPStatus_t HTTPClient_SendHttpData( const TransportInterface_t * pTransport, HTTPClient_GetCurrentTimeFunc_t getTimestampMs, const uint8_t * pData, size_t dataLen ); -/** - * @brief Send the HTTP headers over the transport send interface. - * - * @param[in] pTransport Transport interface. - * @param[in] getTimestampMs Function to retrieve a timestamp in milliseconds. - * @param[in] pRequestHeaders Request headers to send, it includes the buffer - * and length. - * @param[in] reqBodyLen The length of the request body to be sent. This is - * used to generated a Content-Length header. - * @param[in] sendFlags Application provided flags to #HTTPClient_Send. - * - * @return #HTTPSuccess if successful. If there was a network error or less - * bytes than what were specified were sent, then #HTTPNetworkError is - * returned. - */ + HTTPStatus_t HTTPClient_SendHttpHeaders( const TransportInterface_t * pTransport, HTTPClient_GetCurrentTimeFunc_t getTimestampMs, HTTPRequestHeaders_t * pRequestHeaders, @@ -187,17 +162,7 @@ static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState, size_t totalReceived, size_t responseBufferLen ); -/** - * @brief Receive the HTTP response from the network and parse it. - * - * @param[in] pTransport Transport interface. - * @param[in] pResponse Response message to receive data from the network. - * @param[in] pRequestHeaders Request headers for the corresponding HTTP request. - * - * @return Returns #HTTPSuccess if successful. #HTTPNetworkError for a transport - * receive error. Please see #parseHttpResponse and #getFinalResponseStatus for - * other statuses returned. - */ + HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse( const TransportInterface_t * pTransport, HTTPResponse_t * pResponse, const HTTPRequestHeaders_t * pRequestHeaders ); diff --git a/source/include/core_http_client.h b/source/include/core_http_client.h index 70fe835b..8dc2a098 100644 --- a/source/include/core_http_client.h +++ b/source/include/core_http_client.h @@ -737,6 +737,41 @@ HTTPStatus_t HTTPClient_AddRangeHeader( HTTPRequestHeaders_t * pRequestHeaders, int32_t rangeEnd ); /* @[declare_httpclient_addrangeheader] */ +/** + * @brief Send the request headers in @p pRequestHeaders over the transport. + * + * If #HTTP_SEND_DISABLE_CONTENT_LENGTH_FLAG is not set in parameter @p sendFlags, + * then the Content-Length to be sent to the server is automatically written to + * @p 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: + * - #HTTPSecurityAlertExtraneousResponseData + * - #HTTPSecurityAlertInvalidChunkHeader + * - #HTTPSecurityAlertInvalidProtocolVersion + * - #HTTPSecurityAlertInvalidStatusCode + * - #HTTPSecurityAlertInvalidCharacter + * - #HTTPSecurityAlertInvalidContentLength + * + * + * @param[in] pTransport Transport interface, see #TransportInterface_t for + * more information. + * @param[in] getTimestampMs Function to retrieve a timestamp in milliseconds. + * @param[in] pRequestHeaders Request configuration containing the buffer of headers to + * send. + * @param[in] reqBodyLen The length of the request entity in bytes. + * @param[in] sendFlags Flags which modify the behavior of this function. Please see @ref + * http_send_flags for more information. + * + * @return #HTTPSuccess if successful. If there was a network error or less + * bytes than what were specified were sent, then #HTTPNetworkError is + * returned. + * + */ /* @[declare_httpclient_sendhttpheaders] */ HTTPStatus_t HTTPClient_SendHttpHeaders( const TransportInterface_t * pTransport, HTTPClient_GetCurrentTimeFunc_t getTimestampMs, @@ -745,6 +780,19 @@ HTTPStatus_t HTTPClient_SendHttpHeaders( const TransportInterface_t * pTransport uint32_t sendFlags ); /* @[declare_httpclient_sendhttpheaders] */ +/** + * @brief Send the request body in @p pRequestBodyBuf over the transport. + * + * @param[in] pTransport Transport interface, see #TransportInterface_t for + * more information. + * @param[in] getTimestampMs Function to retrieve a timestamp in milliseconds. + * @param[in] pData HTTP request data to send. + * @param[in] dataLen HTTP request data length. + * + * @return #HTTPSuccess if successful. If there was a network error or less + * bytes than what were specified were sent, then #HTTPNetworkError is + * returned. + */ /* @[declare_httpclient_sendhttpdata] */ HTTPStatus_t HTTPClient_SendHttpData( const TransportInterface_t * pTransport, HTTPClient_GetCurrentTimeFunc_t getTimestampMs, @@ -854,6 +902,21 @@ HTTPStatus_t HTTPClient_Send( const TransportInterface_t * pTransport, uint32_t sendFlags ); /* @[declare_httpclient_send] */ +/** + * @brief Receive the HTTP response from the network and parse it. + * + * @param[in] pTransport Transport interface, see #TransportInterface_t for more + * information. + * @param[in] pResponse The response message and some notable response parameters will be + * returned here on success. + * @param[in] pRequestHeaders Request configuration containing the buffer of headers to + * send. + * + * @return Returns #HTTPSuccess if successful. #HTTPNetworkError for a transport + * receive error. Please see #parseHttpResponse and #getFinalResponseStatus for + * other statuses returned. + * + */ /* @[declare_httpclient_receiveandparsehttpresponse] */ HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse( const TransportInterface_t * pTransport, HTTPResponse_t * pResponse, From a8d9f7c313f62cbecd3172f76f70558c0c12ba84 Mon Sep 17 00:00:00 2001 From: Eric Jackson Date: Wed, 8 Nov 2023 14:10:13 -0800 Subject: [PATCH 4/5] Updates code size --- docs/doxygen/include/size_table.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/doxygen/include/size_table.md b/docs/doxygen/include/size_table.md index fed45453..2170e484 100644 --- a/docs/doxygen/include/size_table.md +++ b/docs/doxygen/include/size_table.md @@ -10,7 +10,7 @@ core_http_client.c
3.2K
-
2.5K
+
2.6K
api.c (llhttp) @@ -30,6 +30,6 @@ Total estimates
24.0K
-
20.7K
+
20.8K
From e863c21772fe95d3408af5a0b44d1da06965a3f0 Mon Sep 17 00:00:00 2001 From: Eric Jackson Date: Wed, 8 Nov 2023 14:24:55 -0800 Subject: [PATCH 5/5] Update CBMC --- test/cbmc/proofs/HTTPClient_Send/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cbmc/proofs/HTTPClient_Send/Makefile b/test/cbmc/proofs/HTTPClient_Send/Makefile index 931729ad..064330a3 100644 --- a/test/cbmc/proofs/HTTPClient_Send/Makefile +++ b/test/cbmc/proofs/HTTPClient_Send/Makefile @@ -57,8 +57,8 @@ REMOVE_FUNCTION_BODY += __CPROVER_file_local_core_http_client_c_httpHeaderStrncp # than the total possible iterations in the int32_t to ASCII converation. UNWINDSET += __CPROVER_file_local_core_http_client_c_convertInt32ToAscii.0:11 UNWINDSET += __CPROVER_file_local_core_http_client_c_convertInt32ToAscii.1:11 -UNWINDSET += __CPROVER_file_local_core_http_client_c_receiveAndParseHttpResponse.0:10 -UNWINDSET += __CPROVER_file_local_core_http_client_c_sendHttpData.0:10 +UNWINDSET += HTTPClient_ReceiveAndParseHttpResponse.0:10 +UNWINDSET += HTTPClient_SendHttpData.0:10 # strncmp is used to find if there exists "\r\n\r\n" at the end of the header # buffer. Therefore, we need to unwind strncmp to the length of "\r\n\r\n" + 1.