From 2fb7a1bfb90c4c8d484e4b0c4bd5ae2a594fd6e1 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Mon, 16 Sep 2019 20:17:42 +0300 Subject: HTTP parser: removed unused "exten_start" and "args_start" fields. --- src/test/nxt_http_parse_test.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'src/test/nxt_http_parse_test.c') diff --git a/src/test/nxt_http_parse_test.c b/src/test/nxt_http_parse_test.c index 572e91b2..3e86f6ef 100644 --- a/src/test/nxt_http_parse_test.c +++ b/src/test/nxt_http_parse_test.c @@ -80,7 +80,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = { { .request_line = { nxt_string("XXX-METHOD"), nxt_string("/d.ir/fi+le.ext?key=val"), - nxt_string("ext?key=val"), + nxt_string("ext"), nxt_string("key=val"), "HTTP/1.2", 0, 0, 0, 1 @@ -163,7 +163,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = { nxt_string("GET"), nxt_string("/?#"), nxt_null_string, - nxt_string("#"), + nxt_string(""), "HTTP/1.0", 1, 0, 0, 0 }} @@ -729,31 +729,23 @@ nxt_http_parse_test_request_line(nxt_http_request_parse_t *rp, return NXT_ERROR; } - str.length = (rp->exten_start != NULL) ? rp->target_end - rp->exten_start - : 0; - str.start = rp->exten_start; - - if (str.start != test->exten.start - && !nxt_strstr_eq(&str, &test->exten)) + if (rp->exten.start != test->exten.start + && !nxt_strstr_eq(&rp->exten, &test->exten)) { nxt_log_alert(log, "http parse test case failed:\n" " - request:\n\"%V\"\n" " - exten: \"%V\" (expected: \"%V\")", - request, &str, &test->exten); + request, &rp->exten, &test->exten); return NXT_ERROR; } - str.length = (rp->args_start != NULL) ? rp->target_end - rp->args_start - : 0; - str.start = rp->args_start; - - if (str.start != test->args.start - && !nxt_strstr_eq(&str, &test->args)) + if (rp->args.start != test->args.start + && !nxt_strstr_eq(&rp->args, &test->args)) { nxt_log_alert(log, "http parse test case failed:\n" " - request:\n\"%V\"\n" " - args: \"%V\" (expected: \"%V\")", - request, &str, &test->args); + request, &rp->args, &test->args); return NXT_ERROR; } -- cgit From 3b77e402a903d9f7a6eeb32f7930d8979f8e0c9e Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Mon, 16 Sep 2019 20:17:42 +0300 Subject: HTTP parser: removed unused "plus_in_target" flag. --- src/test/nxt_http_parse_test.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'src/test/nxt_http_parse_test.c') diff --git a/src/test/nxt_http_parse_test.c b/src/test/nxt_http_parse_test.c index 3e86f6ef..6fbda25a 100644 --- a/src/test/nxt_http_parse_test.c +++ b/src/test/nxt_http_parse_test.c @@ -21,8 +21,6 @@ typedef struct { unsigned quoted_target:1; /* target with " " */ unsigned space_in_target:1; - /* target with "+" */ - unsigned plus_in_target:1; } 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, "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("key=val"), "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_string(""), "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, "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, "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_string(""), "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, "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, "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, "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, "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; } - 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; } -- cgit From 6352c21a58d66db99f8f981c37e6d57e62fc24a2 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Tue, 17 Sep 2019 18:40:21 +0300 Subject: HTTP parser: fixed parsing of target after literal space character. In theory, all space characters in request target must be encoded; however, some clients may violate the specification. For the sake of interoperability, Unit supports unencoded space characters. Previously, if there was a space character before the extension or arguments parts, those parts weren't recognized. Also, quoted symbols and complex target weren't detected after a space character. --- src/test/nxt_http_parse_test.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/test/nxt_http_parse_test.c') diff --git a/src/test/nxt_http_parse_test.c b/src/test/nxt_http_parse_test.c index 6fbda25a..5498cb1f 100644 --- a/src/test/nxt_http_parse_test.c +++ b/src/test/nxt_http_parse_test.c @@ -205,6 +205,19 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = { 0, 0, 1 }} }, + { + nxt_string("GET /na %20me.ext?args HTTP/1.0\r\n\r\n"), + NXT_DONE, + &nxt_http_parse_test_request_line, + { .request_line = { + nxt_string("GET"), + nxt_string("/na %20me.ext?args"), + nxt_string("ext"), + nxt_string("args"), + "HTTP/1.0", + 0, 1, 1 + }} + }, { nxt_string("GET / HTTP/1.0 HTTP/1.1\r\n\r\n"), NXT_DONE, @@ -212,7 +225,7 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = { { .request_line = { nxt_string("GET"), nxt_string("/ HTTP/1.0"), - nxt_null_string, + nxt_string("0"), nxt_null_string, "HTTP/1.1", 0, 0, 1 -- cgit