Skip to content

Commit

Permalink
Format (#3)
Browse files Browse the repository at this point in the history
* format
---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
cryi and actions-user authored Jan 17, 2024
1 parent 00677cb commit 4324547
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
14 changes: 9 additions & 5 deletions source/core_http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,9 +872,10 @@ static int httpParserOnHeadersCompleteCallback( llhttp_t * pHttpParser )

/* If there is HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG opt-in we should stop
* parsing here. */
if ( pResponse->respOptionFlags & HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG ) {
if( pResponse->respOptionFlags & HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG )
{
shouldContinueParse = LLHTTP_PAUSE_PARSING;
pResponse->pBody = (const uint8_t*)pParsingContext->pBufferCur;
pResponse->pBody = ( const uint8_t * ) pParsingContext->pBufferCur;
}

return shouldContinueParse;
Expand Down Expand Up @@ -1108,10 +1109,12 @@ static HTTPStatus_t processLlhttpError( const llhttp_t * pHttpParser )
"found when it shouldn't have been." ) );
returnStatus = HTTPSecurityAlertInvalidContentLength;
break;

case HPE_PAUSED:
LogInfo(("User intervention: Parsing stopped by user."));
LogInfo( ( "User intervention: Parsing stopped by user." ) );
returnStatus = HTTPParserPaused;
break;

/* All other error cases cannot be triggered and indicate an error in the
* third-party parsing library if found. */
default:
Expand Down Expand Up @@ -2096,10 +2099,11 @@ HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse( const TransportInterface_t
( totalReceived < pResponse->bufferLen ) ) ? 1U : 0U;
}

if ( returnStatus == HTTPParserPaused && pResponse->respOptionFlags & HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG) {
if( ( returnStatus == HTTPParserPaused ) && pResponse->respOptionFlags & HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG )
{
returnStatus = HTTPSuccess;
/* There may be dangling data if we parse with do not parse body flag. To let libraries built on top of corehttp we expose it through body. */
pResponse->bodyLen = totalReceived - ((uint8_t *)pResponse->pBody - pResponse->pBuffer);
pResponse->bodyLen = totalReceived - ( ( uint8_t * ) pResponse->pBody - pResponse->pBuffer );
}

if( returnStatus == HTTPSuccess )
Expand Down
16 changes: 8 additions & 8 deletions source/include/core_http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
*
* This flag is valid only for #HTTPResponse_t respOptionFlags parameter.
*/
#define HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG 0x1U
#define HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG 0x1U

/**
* @ingroup http_constants
Expand All @@ -185,7 +185,7 @@
* - When the requested range is for the last N bytes of the file.
* In both cases, this value should be used for the "rangeEnd" parameter.
*/
#define HTTP_RANGE_REQUEST_END_OF_FILE -1
#define HTTP_RANGE_REQUEST_END_OF_FILE -1

/**
* @ingroup http_enum_types
Expand Down Expand Up @@ -322,12 +322,12 @@ typedef enum HTTPStatus
HTTPParserPaused,

/**
* @brief An error occurred in the third-party parsing library.
*
* Functions that may return this value:
* - #HTTPClient_Send
* - #HTTPClient_ReadHeader
*/
* @brief An error occurred in the third-party parsing library.
*
* Functions that may return this value:
* - #HTTPClient_Send
* - #HTTPClient_ReadHeader
*/
HTTPParserInternalError,

/**
Expand Down

0 comments on commit 4324547

Please sign in to comment.