This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.1.x by this push:
new 89a12ab Ensure the HTTP protion of the protocol string is upper case
(#7904)
89a12ab is described below
commit 89a12ab730ead2411faf6b05ed3347e3d1143b9f
Author: Susan Hinrichs <[email protected]>
AuthorDate: Tue Jun 1 08:21:24 2021 -0500
Ensure the HTTP protion of the protocol string is upper case (#7904)
(cherry picked from commit 68edae79c0951bbbe19c31afc44ce760e697db48)
---
proxy/hdrs/HTTP.cc | 19 +++++++++----------
proxy/hdrs/unit_tests/test_Hdrs.cc | 3 ++-
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
index 583c3b2..3c241a4 100644
--- a/proxy/hdrs/HTTP.cc
+++ b/proxy/hdrs/HTTP.cc
@@ -1033,19 +1033,19 @@ http_parser_parse_req(HTTPParser *parser, HdrHeap
*heap, HTTPHdrImpl *hh, const
}
goto parse_url;
parse_version4:
- if ((*cur != 'P') && (*cur != 'p')) {
+ if (*cur != 'P') {
goto parse_url;
}
GETPREV(parse_url);
- if ((*cur != 'T') && (*cur != 't')) {
+ if (*cur != 'T') {
goto parse_url;
}
GETPREV(parse_url);
- if ((*cur != 'T') && (*cur != 't')) {
+ if (*cur != 'T') {
goto parse_url;
}
GETPREV(parse_url);
- if ((*cur != 'H') && (*cur != 'h')) {
+ if (*cur != 'H') {
goto parse_url;
}
version_start = cur;
@@ -1297,19 +1297,19 @@ http_parser_parse_resp(HTTPParser *parser, HdrHeap
*heap, HTTPHdrImpl *hh, const
reason_end = nullptr;
version_start = cur = line_start;
- if ((*cur != 'H') && (*cur != 'h')) {
+ if (*cur != 'H') {
goto eoh;
}
GETNEXT(eoh);
- if ((*cur != 'T') && (*cur != 't')) {
+ if (*cur != 'T') {
goto eoh;
}
GETNEXT(eoh);
- if ((*cur != 'T') && (*cur != 't')) {
+ if (*cur != 'T') {
goto eoh;
}
GETNEXT(eoh);
- if ((*cur != 'P') && (*cur != 'p')) {
+ if (*cur != 'P') {
goto eoh;
}
GETNEXT(eoh);
@@ -1438,8 +1438,7 @@ http_parse_version(const char *start, const char *end)
return HTTP_0_9;
}
- if (((start[0] == 'H') || (start[0] == 'h')) && ((start[1] == 'T') ||
(start[1] == 't')) &&
- ((start[2] == 'T') || (start[2] == 't')) && ((start[3] == 'P') ||
(start[3] == 'p')) && (start[4] == '/')) {
+ if ((start[0] == 'H') && (start[1] == 'T') && (start[2] == 'T') && (start[3]
== 'P') && (start[4] == '/')) {
start += 5;
maj = 0;
diff --git a/proxy/hdrs/unit_tests/test_Hdrs.cc
b/proxy/hdrs/unit_tests/test_Hdrs.cc
index 20ecfa8..73022bf 100644
--- a/proxy/hdrs/unit_tests/test_Hdrs.cc
+++ b/proxy/hdrs/unit_tests/test_Hdrs.cc
@@ -45,7 +45,7 @@ TEST_CASE("HdrTestHttpParse", "[proxy][hdrtest]")
int expected_result;
int expected_bytes_consumed;
};
- static const std::array<Test, 20> tests = {{
+ static const std::array<Test, 21> tests = {{
{"GET /index.html HTTP/1.0\r\n", PARSE_RESULT_DONE, 26},
{"GET /index.html HTTP/1.0\r\n\r\n***BODY****", PARSE_RESULT_DONE, 28},
{"GET /index.html HTTP/1.0\r\nUser-Agent: foobar\r\n\r\n***BODY****",
PARSE_RESULT_DONE, 48},
@@ -65,6 +65,7 @@ TEST_CASE("HdrTestHttpParse", "[proxy][hdrtest]")
{"GET /index.html HTTP/1.0\nUser-Agent: foobar\nBoo: foo\n",
PARSE_RESULT_DONE, 53},
{"GET /index.html HTTP/1.0\r\nUser-Agent: foobar\r\n", PARSE_RESULT_DONE,
46},
{"GET /index.html HTTP/1.0\r\n", PARSE_RESULT_DONE, 26},
+ {"GET /index.html hTTP/1.0\r\n", PARSE_RESULT_ERROR, 26},
{"", PARSE_RESULT_ERROR, 0},
}};