You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2021/04/29 20:37:24 UTC
[GitHub] [trafficserver] shinrich opened a new pull request #7766: Clean up HTTP version processing
shinrich opened a new pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766
This is an extended version of PR #7706.
@zwoop started reviewing PR #7706 and reasonable asked, why do we have two different structures/enums tracking HTTP versions. This PR gets rid of the HostDBApplicationInfo::HTTPVersion that was used in HostDBInfo. It replaces it with HTTPVersion which is used everywhere else.
Also adjust HTTPVersion to be smaller (2 uint8_t's) and stored as major and minor versions since that is how most cases were using the data. Added some constants for our current HTTP versions to get rid of inline constructors.
Because of the elimination of the HostDBApplicationInfo::HTTPVersion, we don't have to do the conversion function that was in PR #7706. Instead we can just assign the version from one member to another.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] shinrich merged pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
shinrich merged pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] shinrich commented on pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
shinrich commented on pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#issuecomment-831549946
Note, this change needs the HostDB version to be incremented if it is not already for the target release.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
SolidWallOfCode commented on a change in pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#discussion_r623436230
##########
File path: proxy/hdrs/HTTP.h
##########
@@ -749,7 +758,7 @@ HTTPVersion::operator!=(const HTTPVersion &hv) const
inline int
HTTPVersion::operator>(const HTTPVersion &hv) const
{
- return (m_version > hv.m_version);
+ return *this == hv || !(*this < hv);
Review comment:
Optionally, if you want it optimally fast, do
```
return vmajor > hv.vmajor || (vmajor == hv.vmajor && vminor > hv.vminor);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
SolidWallOfCode commented on a change in pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#discussion_r624558222
##########
File path: proxy/hdrs/HTTP.h
##########
@@ -700,29 +696,42 @@ class HTTPHdr : public MIMEHdr
/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
-inline HTTPVersion::HTTPVersion(int32_t version) : m_version(version) {}
+inline HTTPVersion::HTTPVersion(int version)
+{
+ vmajor = (version & 0xFFFF0000) >> 16;
Review comment:
It looks more consistent with the next line, and avoids any issues with the sign bit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
SolidWallOfCode commented on a change in pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#discussion_r623433380
##########
File path: proxy/hdrs/HTTP.h
##########
@@ -247,10 +243,34 @@ enum HTTPType {
HTTP_TYPE_RESPONSE,
};
+class HTTPVersion
Review comment:
This should be moved to "tscore".
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] shinrich commented on a change in pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
shinrich commented on a change in pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#discussion_r625375029
##########
File path: include/tscore/HTTPVersion.h
##########
@@ -0,0 +1,152 @@
+/** @file
+
+ HTTPVersion - class to track the HTTP version
+
+ @section license License
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#pragma once
+
+class HTTPVersion
+{
+public:
+ HTTPVersion() {}
+ HTTPVersion(HTTPVersion const &that) = default;
+ explicit HTTPVersion(int version);
+ constexpr HTTPVersion(uint8_t ver_major, uint8_t ver_minor);
+
+ int operator==(const HTTPVersion &hv) const;
+ int operator!=(const HTTPVersion &hv) const;
+ int operator>(const HTTPVersion &hv) const;
+ int operator<(const HTTPVersion &hv) const;
+ int operator>=(const HTTPVersion &hv) const;
+ int operator<=(const HTTPVersion &hv) const;
+
+ uint8_t get_major() const;
+ uint8_t get_minor() const;
+ int get_flat_version() const;
+
+private:
+ uint8_t vmajor = 0;
+ uint8_t vminor = 0;
+};
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline HTTPVersion::HTTPVersion(int version)
+{
+ vmajor = (version >> 16) & 0xFFFF;
+ vminor = version & 0xFFFF;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline constexpr HTTPVersion::HTTPVersion(uint8_t ver_major, uint8_t ver_minor) : vmajor(ver_major), vminor(ver_minor) {}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline uint8_t
+HTTPVersion::get_major() const
+{
+ return vmajor;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline uint8_t
+HTTPVersion::get_minor() const
+{
+ return vminor;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::get_flat_version() const
+{
+ return vmajor << 16 | vminor;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator==(const HTTPVersion &hv) const
+{
+ return vmajor == hv.get_major() && vminor == hv.get_minor();
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator!=(const HTTPVersion &hv) const
+{
+ return !(*this == hv);
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator>(const HTTPVersion &hv) const
+{
+ return vmajor > hv.get_major() || (vmajor == hv.get_major() && vminor > hv.get_minor());
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator<(const HTTPVersion &hv) const
+{
+ return vmajor < hv.get_major() || (vmajor == hv.get_major() && vminor < hv.get_minor());
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator>=(const HTTPVersion &hv) const
+{
+ return vmajor > hv.get_major() || (vmajor == hv.get_major() && vminor >= hv.get_minor());
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator<=(const HTTPVersion &hv) const
+{
+ return vmajor < hv.get_major() || (vmajor == hv.get_major() && vminor <= hv.get_minor());
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+constexpr HTTPVersion HTTP_INVALID{0, 0};
+constexpr HTTPVersion HTTP_0_9{0, 9};
+constexpr HTTPVersion HTTP_1_0{1, 0};
+constexpr HTTPVersion HTTP_1_1{1, 1};
+constexpr HTTPVersion HTTP_2_0{2, 0};
Review comment:
Will once we support QUIC to origin.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
SolidWallOfCode commented on a change in pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#discussion_r623432528
##########
File path: iocore/hostdb/I_HostDBProcessor.h
##########
@@ -31,6 +31,7 @@
#include "I_EventSystem.h"
#include "SRV.h"
#include "P_RefCountCache.h"
+#include "HTTP.h"
Review comment:
Oh, that's not good. Introducing a cycle in the dependency graph.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] shinrich commented on a change in pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
shinrich commented on a change in pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#discussion_r623445372
##########
File path: proxy/hdrs/HTTP.h
##########
@@ -700,29 +696,42 @@ class HTTPHdr : public MIMEHdr
/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
-inline HTTPVersion::HTTPVersion(int32_t version) : m_version(version) {}
+inline HTTPVersion::HTTPVersion(int version)
+{
+ vmajor = (version & 0xFFFF0000) >> 16;
Review comment:
Why?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] zwoop commented on a change in pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
zwoop commented on a change in pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#discussion_r625371953
##########
File path: include/tscore/HTTPVersion.h
##########
@@ -0,0 +1,152 @@
+/** @file
+
+ HTTPVersion - class to track the HTTP version
+
+ @section license License
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#pragma once
+
+class HTTPVersion
+{
+public:
+ HTTPVersion() {}
+ HTTPVersion(HTTPVersion const &that) = default;
+ explicit HTTPVersion(int version);
+ constexpr HTTPVersion(uint8_t ver_major, uint8_t ver_minor);
+
+ int operator==(const HTTPVersion &hv) const;
+ int operator!=(const HTTPVersion &hv) const;
+ int operator>(const HTTPVersion &hv) const;
+ int operator<(const HTTPVersion &hv) const;
+ int operator>=(const HTTPVersion &hv) const;
+ int operator<=(const HTTPVersion &hv) const;
+
+ uint8_t get_major() const;
+ uint8_t get_minor() const;
+ int get_flat_version() const;
+
+private:
+ uint8_t vmajor = 0;
+ uint8_t vminor = 0;
+};
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline HTTPVersion::HTTPVersion(int version)
+{
+ vmajor = (version >> 16) & 0xFFFF;
+ vminor = version & 0xFFFF;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline constexpr HTTPVersion::HTTPVersion(uint8_t ver_major, uint8_t ver_minor) : vmajor(ver_major), vminor(ver_minor) {}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline uint8_t
+HTTPVersion::get_major() const
+{
+ return vmajor;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline uint8_t
+HTTPVersion::get_minor() const
+{
+ return vminor;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::get_flat_version() const
+{
+ return vmajor << 16 | vminor;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator==(const HTTPVersion &hv) const
+{
+ return vmajor == hv.get_major() && vminor == hv.get_minor();
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator!=(const HTTPVersion &hv) const
+{
+ return !(*this == hv);
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator>(const HTTPVersion &hv) const
+{
+ return vmajor > hv.get_major() || (vmajor == hv.get_major() && vminor > hv.get_minor());
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator<(const HTTPVersion &hv) const
+{
+ return vmajor < hv.get_major() || (vmajor == hv.get_major() && vminor < hv.get_minor());
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator>=(const HTTPVersion &hv) const
+{
+ return vmajor > hv.get_major() || (vmajor == hv.get_major() && vminor >= hv.get_minor());
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+inline int
+HTTPVersion::operator<=(const HTTPVersion &hv) const
+{
+ return vmajor < hv.get_major() || (vmajor == hv.get_major() && vminor <= hv.get_minor());
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+constexpr HTTPVersion HTTP_INVALID{0, 0};
+constexpr HTTPVersion HTTP_0_9{0, 9};
+constexpr HTTPVersion HTTP_1_0{1, 0};
+constexpr HTTPVersion HTTP_1_1{1, 1};
+constexpr HTTPVersion HTTP_2_0{2, 0};
Review comment:
Do we not need a HTTP_3_0 for QUIC?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] zwoop commented on pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
zwoop commented on pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#issuecomment-832768904
Cherry-picked to v9.1.x branch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
SolidWallOfCode commented on a change in pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#discussion_r623436779
##########
File path: proxy/hdrs/HTTP.h
##########
@@ -758,7 +767,7 @@ HTTPVersion::operator>(const HTTPVersion &hv) const
inline int
HTTPVersion::operator<(const HTTPVersion &hv) const
{
- return (m_version < hv.m_version);
+ return vmajor < hv.get_major() || (vmajor == hv.get_major() && vminor < hv.get_minor());
Review comment:
Wait - this is what I recommended on the previous method. Might be worth it to not re-use, but ultimately I suspect it doesn't matter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
SolidWallOfCode commented on a change in pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#discussion_r623435092
##########
File path: proxy/hdrs/HTTP.h
##########
@@ -749,7 +758,7 @@ HTTPVersion::operator!=(const HTTPVersion &hv) const
inline int
HTTPVersion::operator>(const HTTPVersion &hv) const
{
- return (m_version > hv.m_version);
+ return *this == hv || !(*this < hv);
Review comment:
Flip, don't invert - `return *this == hv || hv < *this;`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #7766: Clean up HTTP version processing
Posted by GitBox <gi...@apache.org>.
SolidWallOfCode commented on a change in pull request #7766:
URL: https://github.com/apache/trafficserver/pull/7766#discussion_r623434016
##########
File path: proxy/hdrs/HTTP.h
##########
@@ -700,29 +696,42 @@ class HTTPHdr : public MIMEHdr
/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
-inline HTTPVersion::HTTPVersion(int32_t version) : m_version(version) {}
+inline HTTPVersion::HTTPVersion(int version)
+{
+ vmajor = (version & 0xFFFF0000) >> 16;
Review comment:
Better as `vmajor = (version >> 16) & 0xFFFF;`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org