Merge pull request #6862 from Yurunsoft/fix-header-space
Fix the problem of parsing http protocol when the request header lacks spaces
This commit is contained in:
commit
54cb9070b3
|
@ -100,6 +100,7 @@ typedef enum HTTP_PARSER_STATE {
|
||||||
HTTP_PARSER_CHUNK,
|
HTTP_PARSER_CHUNK,
|
||||||
HTTP_PARSER_END,
|
HTTP_PARSER_END,
|
||||||
HTTP_PARSER_ERROR,
|
HTTP_PARSER_ERROR,
|
||||||
|
HTTP_PARSER_OPTIONAL_SP
|
||||||
} HTTP_PARSER_STATE;
|
} HTTP_PARSER_STATE;
|
||||||
|
|
||||||
typedef enum HTTP_AUTH_TYPE {
|
typedef enum HTTP_AUTH_TYPE {
|
||||||
|
|
|
@ -744,6 +744,15 @@ static int32_t httpParserOnSp(HttpParser *parser, HTTP_PARSER_STATE state, const
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t httpParserOnOptionalSp(HttpParser *parser, HTTP_PARSER_STATE state, const char c, int32_t *again) {
|
||||||
|
int32_t ok = 0;
|
||||||
|
if (c != ' ') {
|
||||||
|
*again = 1;
|
||||||
|
httpPopStack(parser);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t httpParserOnStatusCode(HttpParser *parser, HTTP_PARSER_STATE state, const char c, int32_t *again) {
|
static int32_t httpParserOnStatusCode(HttpParser *parser, HTTP_PARSER_STATE state, const char c, int32_t *again) {
|
||||||
HttpContext *pContext = parser->pContext;
|
HttpContext *pContext = parser->pContext;
|
||||||
int32_t ok = 0;
|
int32_t ok = 0;
|
||||||
|
@ -867,7 +876,7 @@ static int32_t httpParserOnHeader(HttpParser *parser, HTTP_PARSER_STATE state, c
|
||||||
}
|
}
|
||||||
httpPushStack(parser, HTTP_PARSER_CRLF);
|
httpPushStack(parser, HTTP_PARSER_CRLF);
|
||||||
httpPushStack(parser, HTTP_PARSER_HEADER_VAL);
|
httpPushStack(parser, HTTP_PARSER_HEADER_VAL);
|
||||||
httpPushStack(parser, HTTP_PARSER_SP);
|
httpPushStack(parser, HTTP_PARSER_OPTIONAL_SP);
|
||||||
httpPushStack(parser, HTTP_PARSER_HEADER_KEY);
|
httpPushStack(parser, HTTP_PARSER_HEADER_KEY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1061,6 +1070,10 @@ static int32_t httpParseChar(HttpParser *parser, const char c, int32_t *again) {
|
||||||
ok = httpParserOnSp(parser, state, c, again);
|
ok = httpParserOnSp(parser, state, c, again);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (state == HTTP_PARSER_OPTIONAL_SP) {
|
||||||
|
ok = httpParserOnOptionalSp(parser, state, c, again);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (state == HTTP_PARSER_STATUS_CODE) {
|
if (state == HTTP_PARSER_STATUS_CODE) {
|
||||||
ok = httpParserOnStatusCode(parser, state, c, again);
|
ok = httpParserOnStatusCode(parser, state, c, again);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue