in source/core_http_client.c [1022:1132]
static HTTPStatus_t processHttpParserError( const http_parser * pHttpParser )
{
HTTPStatus_t returnStatus = HTTPSuccess;
assert( pHttpParser != NULL );
switch( ( enum http_errno ) ( pHttpParser->http_errno ) )
{
case HPE_OK:
/* There were no errors. */
break;
case HPE_INVALID_EOF_STATE:
/* In this case the parser was passed a length of zero, which indicates
* an EOF from the server, in the middle of parsing the response.
* This case is already handled by checking HTTPParsingContext_t.state. */
break;
case HPE_HEADER_OVERFLOW:
LogError( ( "Response parsing error: Header byte limit "
"exceeded: HeaderByteLimit=%u",
HTTP_MAX_RESPONSE_HEADERS_SIZE_BYTES ) );
returnStatus = HTTPSecurityAlertResponseHeadersSizeLimitExceeded;
break;
case HPE_CLOSED_CONNECTION:
LogError( ( "Response parsing error: Data received past complete "
"response with \"Connection: close\" header present." ) );
returnStatus = HTTPSecurityAlertExtraneousResponseData;
break;
case HPE_INVALID_CHUNK_SIZE:
/* http_parser_execute() does not give feedback on the exact failing
* character and location. */
LogError( ( "Response parsing error: Invalid character found in "
"chunk header." ) );
returnStatus = HTTPSecurityAlertInvalidChunkHeader;
break;
case HPE_INVALID_VERSION:
/* http_parser_execute() does not give feedback on the exact failing
* character and location. */
LogError( ( "Response parsing error: Invalid character found in "
"HTTP protocol version." ) );
returnStatus = HTTPSecurityAlertInvalidProtocolVersion;
break;
case HPE_INVALID_STATUS:
/* There could be an invalid character or the status code number
* could be out of range. This feedback is not given back by the
* http-parser library. */
LogError( ( "Response parsing error: Invalid Status code." ) );
returnStatus = HTTPSecurityAlertInvalidStatusCode;
break;
case HPE_STRICT:
case HPE_INVALID_CONSTANT:
LogError( ( "Response parsing error: Invalid character found in "
"Status-Line or header delimiters." ) );
returnStatus = HTTPSecurityAlertInvalidCharacter;
break;
case HPE_LF_EXPECTED:
LogError( ( "Response parsing error: Expected line-feed in header "
"not found." ) );
returnStatus = HTTPSecurityAlertInvalidCharacter;
break;
case HPE_INVALID_HEADER_TOKEN:
/* http_parser_execute() does not give feedback on the exact failing
* character and location. */
LogError( ( "Response parsing error: Invalid character found in "
"headers." ) );
returnStatus = HTTPSecurityAlertInvalidCharacter;
break;
case HPE_INVALID_CONTENT_LENGTH:
/* http_parser_execute() does not give feedback on the exact failing
* character and location. */
LogError( ( "Response parsing error: Invalid character found in "
"content-length headers." ) );
returnStatus = HTTPSecurityAlertInvalidContentLength;
break;
case HPE_UNEXPECTED_CONTENT_LENGTH:
LogError( ( "Response parsing error: A Content-Length header was "
"found when it shouldn't have been." ) );
returnStatus = HTTPSecurityAlertInvalidContentLength;
break;
/* All other error cases cannot be triggered and indicate an error in the
* third-party parsing library if found. */
default:
LogError( ( "Error in third-party http-parser library." ) );
returnStatus = HTTPParserInternalError;
break;
}
/* Errors with CB_ prepending are manual returns of non-zero in the
* response parsing callback. */
LogDebug( ( "http-parser errno description: %s",
http_errno_description( HTTP_PARSER_ERRNO( pHttpParser ) ) ) );
return returnStatus;
}