in source/core_http_client.c [701:754]
static int httpParserOnHeaderFieldCallback( http_parser * pHttpParser,
const char * pLoc,
size_t length )
{
HTTPParsingContext_t * pParsingContext = NULL;
HTTPResponse_t * pResponse = NULL;
assert( pHttpParser != NULL );
assert( pHttpParser->data != NULL );
assert( pLoc != NULL );
pParsingContext = ( HTTPParsingContext_t * ) ( pHttpParser->data );
pResponse = pParsingContext->pResponse;
assert( pResponse != NULL );
/* If this is the first time httpParserOnHeaderFieldCallback() has been
* invoked on a response, then the start of the response headers is NULL. */
if( pResponse->pHeaders == NULL )
{
pResponse->pHeaders = ( const uint8_t * ) pLoc;
}
/* Set the location of what to parse next. */
pParsingContext->pBufferCur = pLoc + length;
/* The httpParserOnHeaderFieldCallback() always follows the
* httpParserOnHeaderValueCallback() if there is another header field. When
* httpParserOnHeaderValueCallback() is not called in succession, then a
* complete header has been found. */
processCompleteHeader( pParsingContext );
/* If httpParserOnHeaderFieldCallback() is invoked in succession, then the
* last time http_parser_execute() was called only part of the header field
* was parsed. The indication of successive invocations is a non-NULL
* pParsingContext->pLastHeaderField. */
if( pParsingContext->pLastHeaderField == NULL )
{
pParsingContext->pLastHeaderField = pLoc;
pParsingContext->lastHeaderFieldLen = length;
}
else
{
assert( pParsingContext->lastHeaderFieldLen <= SIZE_MAX - length );
pParsingContext->lastHeaderFieldLen += length;
}
LogDebug( ( "Response parsing: Found a header field: "
"HeaderField=%.*s",
( int ) length,
pLoc ) );
return HTTP_PARSER_CONTINUE_PARSING;
}