You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2021/08/03 21:37:25 UTC
[trafficserver] 02/02: Minor updates to HTTP version validation
(#8189)
This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch 9.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 152d6eafdf53deebb8c403928d66550cf0a0c9d6
Author: Bryan Call <bc...@apache.org>
AuthorDate: Tue Aug 3 14:03:04 2021 -0700
Minor updates to HTTP version validation (#8189)
Renamed the functions to be more explicit about only supporting HTTP/1.x
Changed the version check to be only a logic statement
(cherry picked from commit c5105cd0ec77b71a15cf01b61b1ddbb07a8d44b8)
Conflicts:
proxy/hdrs/HTTP.h
---
proxy/hdrs/HTTP.cc | 15 ++++++---------
proxy/hdrs/HTTP.h | 2 +-
proxy/http/HttpSM.cc | 2 +-
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
index 793f6e8..c0b16cf 100644
--- a/proxy/hdrs/HTTP.cc
+++ b/proxy/hdrs/HTTP.cc
@@ -633,26 +633,23 @@ http_hdr_type_set(HTTPHdrImpl *hh, HTTPType type)
-------------------------------------------------------------------------*/
bool
-is_version_supported(const uint8_t major, const uint8_t minor)
+is_http1_version(const uint8_t major, const uint8_t minor)
{
- if (major == 1) {
- return minor == 1 || minor == 0;
- }
-
- return false;
+ // Return true if 1.1 or 1.0
+ return (major == 1) && (minor == 1 || minor == 0);
}
bool
-is_http_hdr_version_supported(const HTTPVersion &http_version)
+is_http1_hdr_version_supported(const HTTPVersion &http_version)
{
- return is_version_supported(http_version.get_major(), http_version.get_minor());
+ return is_http1_version(http_version.get_major(), http_version.get_minor());
}
bool
http_hdr_version_set(HTTPHdrImpl *hh, const HTTPVersion &ver)
{
hh->m_version = ver;
- return is_version_supported(ver.get_major(), ver.get_minor());
+ return is_http1_version(ver.get_major(), ver.get_minor());
}
/*-------------------------------------------------------------------------
diff --git a/proxy/hdrs/HTTP.h b/proxy/hdrs/HTTP.h
index dabde58..52602af 100644
--- a/proxy/hdrs/HTTP.h
+++ b/proxy/hdrs/HTTP.h
@@ -460,7 +460,7 @@ HTTPValRange* http_parse_range (const char *buf, Arena *arena);
*/
HTTPValTE *http_parse_te(const char *buf, int len, Arena *arena);
-inkcoreapi bool is_http_hdr_version_supported(const HTTPVersion &http_version);
+bool is_http1_hdr_version_supported(const HTTPVersion &http_version);
class IOBufferReader;
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 68a6343..f461287 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -823,7 +823,7 @@ HttpSM::state_read_client_request_header(int event, void *data)
t_state.http_return_code = HTTP_STATUS_REQUEST_URI_TOO_LONG :
t_state.http_return_code = HTTP_STATUS_NONE;
- if (!is_http_hdr_version_supported(t_state.hdr_info.client_request.version_get())) {
+ if (!is_http1_hdr_version_supported(t_state.hdr_info.client_request.version_get())) {
t_state.http_return_code = HTTP_STATUS_HTTPVER_NOT_SUPPORTED;
}