Skip to content

Commit

Permalink
Disable strict mode and remove system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
muneebahmed10 committed Jan 21, 2022
1 parent ab4ce60 commit 1227e7a
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 2,807 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: ["**"]
pull_request:
branches: [main]
branches: ["**"]
workflow_dispatch:

jobs:
Expand Down
8 changes: 4 additions & 4 deletions docs/doxygen/include/size_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</tr>
<tr>
<td>core_http_client.c</td>
<td><center>3.3K</center></td>
<td><center>2.6K</center></td>
<td><center>3.2K</center></td>
<td><center>2.5K</center></td>
</tr>
<tr>
<td>api.c (llhttp)</td>
Expand All @@ -29,7 +29,7 @@
</tr>
<tr>
<td><b>Total estimates</b></td>
<td><b><center>24.1K</center></b></td>
<td><b><center>20.8K</center></b></td>
<td><b><center>24.0K</center></b></td>
<td><b><center>20.7K</center></b></td>
</tr>
</table>
2 changes: 2 additions & 0 deletions lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ chk
chunked
colspan
com
cond
config
configpagestyle
const
Expand All @@ -42,6 +43,7 @@ defgroup
doesn
doxygen
endcode
endcond
endif
enums
eof
Expand Down
18 changes: 13 additions & 5 deletions source/core_http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ static int findHeaderValueParserCallback( llhttp_t * pHttpParser,
*
* @param[in] pHttpParser Parsing object containing state and callback context.
*
* @return Returns #HTTP_PARSER_STOP_PARSING for the parser to halt further
* @return Returns #LLHTTP_STOP_PARSING_NO_HEADER for the parser to halt further
* execution, as all headers have been parsed in the response.
*/
static int findHeaderOnHeaderCompleteCallback( llhttp_t * pHttpParser );
Expand Down Expand Up @@ -1033,6 +1033,9 @@ static HTTPStatus_t processLlhttpError( const llhttp_t * pHttpParser )

assert( pHttpParser != NULL );

/* llhttp_get_err_pos() may be used to get exact error locations, which was
* not possible with the previous http-parser. */

switch( llhttp_get_errno( pHttpParser ) )
{
case HPE_OK:
Expand Down Expand Up @@ -1069,7 +1072,7 @@ static HTTPStatus_t processLlhttpError( const llhttp_t * pHttpParser )
* character and location. */
LogError( ( "Response parsing error: Invalid character found in "
"HTTP protocol version." ) );
//llhttp_get_error_pos( pHttpParser );

returnStatus = HTTPSecurityAlertInvalidProtocolVersion;
break;

Expand Down Expand Up @@ -2357,9 +2360,14 @@ static int findHeaderOnHeaderCompleteCallback( llhttp_t * pHttpParser )
( int ) ( pContext->fieldLen ),
pContext->pField ) );

/* No further parsing is required; thus, indicate the parser to stop parsing. */
//return HTTP_PARSER_STOP_PARSING;
return -1;
/* No further parsing is required; thus, indicate the parser to stop parsing.
* The documentation for on_headers_complete states that this function can
* return 1 to indicate the response has no body, or -1 to indicate error.
* Returning 1 causes llhttp_execute() to exit with success, while -1
* causes it to return the HPE_CB_HEADERS_COMPLETE error code (in strict
* mode) or success (in non-strict mode). We are fine with the success
* return value, as llhttp_execute will not be invoked again in the same call.*/
return LLHTTP_STOP_PARSING_NO_HEADER;
}

/*-----------------------------------------------------------*/
Expand Down
18 changes: 15 additions & 3 deletions source/include/core_http_client_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
#ifndef CORE_HTTP_CLIENT_PRIVATE_H_
#define CORE_HTTP_CLIENT_PRIVATE_H_

/* http-parser defaults this to 1, llhttp to 0. */
/**
* @cond DOXYGEN_IGNORE
* http-parser defaults this to 1, llhttp to 0.
*/
#ifndef LLHTTP_STRICT_MODE
#define LLHTTP_STRICT_MODE 1
#define LLHTTP_STRICT_MODE 0
#endif
/** @endcond */

/* Third-party llhttp include. */
#include "llhttp.h"
Expand Down Expand Up @@ -165,14 +169,22 @@
* further execution.
*/
#define LLHTTP_STOP_PARSING HPE_USER
#define HTTP_PARSER_STOP_PARSING 1

/**
* @brief Return value for llhttp_t.on_headers_complete to signal
* that the HTTP response has no body and to halt further execution.
*/
#define LLHTTP_STOP_PARSING_NO_BODY 1

/**
* @brief Return value for llhttp_t.on_headers_complete to signal
* halting further execution. This is the same return value that
* indicates the HTTP response has no body, but unlike the -1 error
* code, gives consistent return values for llhttp_execute in both
* strict and non-strict modes.
*/
#define LLHTTP_STOP_PARSING_NO_HEADER 1

/**
* @brief The minimum request-line in the headers has a possible one character
* custom method and a single forward / or asterisk * for the path:
Expand Down
Loading

0 comments on commit 1227e7a

Please sign in to comment.