in source/core_http_client.c [2299:2354]
static int findHeaderValueParserCallback( http_parser * pHttpParser,
const char * pValueLoc,
size_t valueLen )
{
int retCode = HTTP_PARSER_CONTINUE_PARSING;
findHeaderContext_t * pContext = NULL;
assert( pHttpParser != NULL );
assert( pHttpParser->data != NULL );
assert( pValueLoc != NULL );
pContext = ( findHeaderContext_t * ) pHttpParser->data;
assert( pContext->pField != NULL );
assert( pContext->fieldLen > 0U );
assert( pContext->pValueLoc != NULL );
assert( pContext->pValueLen != NULL );
/* The header value found flag should not be set. */
assert( pContext->valueFound == 0U );
if( pContext->fieldFound == 1U )
{
LogDebug( ( "Found header value in response: "
"RequestedField=%.*s, ValueLocation=0x%p",
( int ) ( pContext->fieldLen ), pContext->pField, pValueLoc ) );
if( valueLen > 0U )
{
/* Populate the output parameters with the location of the header
* value in the response buffer. */
*pContext->pValueLoc = pValueLoc;
*pContext->pValueLen = valueLen;
}
else
{
/* It is not invalid according to RFC 2616 to have an empty header
* value. */
*pContext->pValueLoc = NULL;
*pContext->pValueLen = 0U;
}
/* Set the header value found flag. */
pContext->valueFound = 1U;
/* As we have found the value associated with the header, we don't need
* to parse the response any further. */
retCode = HTTP_PARSER_STOP_PARSING;
}
else
{
/* Empty else for MISRA 15.7 compliance. */
}
return retCode;
}