HTTP parser: removed unused "plus_in_target" flag.

This commit is contained in:
Valentin Bartenev
2019-09-16 20:17:42 +03:00
parent 56f4085b9d
commit 3b77e402a9
3 changed files with 15 additions and 48 deletions

View File

@@ -47,7 +47,6 @@ typedef enum {
NXT_HTTP_TARGET_DOT, /* . */ NXT_HTTP_TARGET_DOT, /* . */
NXT_HTTP_TARGET_ARGS_MARK, /* ? */ NXT_HTTP_TARGET_ARGS_MARK, /* ? */
NXT_HTTP_TARGET_QUOTE_MARK, /* % */ NXT_HTTP_TARGET_QUOTE_MARK, /* % */
NXT_HTTP_TARGET_PLUS, /* + */
} nxt_http_target_traps_e; } nxt_http_target_traps_e;
@@ -57,7 +56,7 @@ static const uint8_t nxt_http_target_chars[256] nxt_aligned(64) = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* \s ! " # $ % & ' ( ) * + , - . / */ /* \s ! " # $ % & ' ( ) * + , - . / */
1, 0, 0, 2, 0, 8, 0, 0, 0, 0, 0, 9, 0, 0, 6, 5, 1, 0, 0, 2, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 6, 5,
/* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7,
@@ -295,10 +294,6 @@ nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,
rp->quoted_target = 1; rp->quoted_target = 1;
goto rest_of_target; goto rest_of_target;
case NXT_HTTP_TARGET_PLUS:
rp->plus_in_target = 1;
continue;
case NXT_HTTP_TARGET_HASH: case NXT_HTTP_TARGET_HASH:
rp->complex_target = 1; rp->complex_target = 1;
goto rest_of_target; goto rest_of_target;
@@ -898,9 +893,6 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
exten = u + 1; exten = u + 1;
*u++ = ch; *u++ = ch;
continue; continue;
case '+':
rp->plus_in_target = 1;
/* Fall through. */
default: default:
*u++ = ch; *u++ = ch;
continue; continue;
@@ -932,9 +924,6 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
goto args; goto args;
case '#': case '#':
goto done; goto done;
case '+':
rp->plus_in_target = 1;
/* Fall through. */
default: default:
state = sw_normal; state = sw_normal;
*u++ = ch; *u++ = ch;
@@ -969,9 +958,6 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
goto args; goto args;
case '#': case '#':
goto done; goto done;
case '+':
rp->plus_in_target = 1;
/* Fall through. */
default: default:
state = sw_normal; state = sw_normal;
*u++ = ch; *u++ = ch;
@@ -1013,9 +999,6 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
goto args; goto args;
case '#': case '#':
goto done; goto done;
case '+':
rp->plus_in_target = 1;
/* Fall through. */
default: default:
state = sw_normal; state = sw_normal;
*u++ = ch; *u++ = ch;
@@ -1090,10 +1073,6 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
continue; continue;
} }
if (ch == '+') {
rp->plus_in_target = 1;
}
state = saved_state; state = saved_state;
goto again; goto again;
} }

View File

@@ -57,16 +57,14 @@ struct nxt_http_request_parse_s {
uint32_t field_hash; uint32_t field_hash;
/* target with "/." */ /* target with "/." */
unsigned complex_target:1; uint8_t complex_target; /* 1 bit */
/* target with "%" */ /* target with "%" */
unsigned quoted_target:1; uint8_t quoted_target; /* 1 bit */
/* target with " " */ /* target with " " */
unsigned space_in_target:1; uint8_t space_in_target; /* 1 bit */
/* target with "+" */
unsigned plus_in_target:1;
/* Preserve encoded '/' (%2F) and '%' (%25). */ /* Preserve encoded '/' (%2F) and '%' (%25). */
unsigned encoded_slashes:1; uint8_t encoded_slashes; /* 1 bit */
}; };

View File

@@ -21,8 +21,6 @@ typedef struct {
unsigned quoted_target:1; unsigned quoted_target:1;
/* target with " " */ /* target with " " */
unsigned space_in_target:1; unsigned space_in_target:1;
/* target with "+" */
unsigned plus_in_target:1;
} nxt_http_parse_test_request_line_t; } nxt_http_parse_test_request_line_t;
@@ -70,7 +68,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_null_string, nxt_null_string,
nxt_null_string, nxt_null_string,
"HTTP/1.0", "HTTP/1.0",
0, 0, 0, 0 0, 0, 0
}} }}
}, },
{ {
@@ -83,7 +81,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_string("ext"), nxt_string("ext"),
nxt_string("key=val"), nxt_string("key=val"),
"HTTP/1.2", "HTTP/1.2",
0, 0, 0, 1 0, 0, 0
}} }}
}, },
{ {
@@ -96,7 +94,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_null_string, nxt_null_string,
nxt_string(""), nxt_string(""),
"HTTP/1.0", "HTTP/1.0",
0, 0, 0, 0 0, 0, 0
}} }}
}, },
{ {
@@ -139,7 +137,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_null_string, nxt_null_string,
nxt_null_string, nxt_null_string,
"HTTP/1.0", "HTTP/1.0",
1, 0, 0, 0 1, 0, 0
}} }}
}, },
{ {
@@ -152,7 +150,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_null_string, nxt_null_string,
nxt_null_string, nxt_null_string,
"HTTP/1.0", "HTTP/1.0",
1, 0, 0, 0 1, 0, 0
}} }}
}, },
{ {
@@ -165,7 +163,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_null_string, nxt_null_string,
nxt_string(""), nxt_string(""),
"HTTP/1.0", "HTTP/1.0",
1, 0, 0, 0 1, 0, 0
}} }}
}, },
{ {
@@ -178,7 +176,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_null_string, nxt_null_string,
nxt_null_string, nxt_null_string,
"HTTP/1.0", "HTTP/1.0",
1, 0, 0, 0 1, 0, 0
}} }}
}, },
{ {
@@ -191,7 +189,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_null_string, nxt_null_string,
nxt_null_string, nxt_null_string,
"HTTP/1.0", "HTTP/1.0",
0, 1, 0, 0 0, 1, 0
}} }}
}, },
{ {
@@ -204,7 +202,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_null_string, nxt_null_string,
nxt_null_string, nxt_null_string,
"HTTP/1.0", "HTTP/1.0",
0, 0, 1, 0 0, 0, 1
}} }}
}, },
{ {
@@ -217,7 +215,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_null_string, nxt_null_string,
nxt_null_string, nxt_null_string,
"HTTP/1.1", "HTTP/1.1",
0, 0, 1, 0 0, 0, 1
}} }}
}, },
{ {
@@ -782,14 +780,6 @@ nxt_http_parse_test_request_line(nxt_http_request_parse_t *rp,
return NXT_ERROR; return NXT_ERROR;
} }
if (rp->plus_in_target != test->plus_in_target) {
nxt_log_alert(log, "http parse test case failed:\n"
" - request:\n\"%V\"\n"
" - plus_in_target: %d (expected: %d)",
request, rp->plus_in_target, test->plus_in_target);
return NXT_ERROR;
}
return NXT_OK; return NXT_OK;
} }