diff --git a/iocore/net/QUICNetVConnection_quiche.cc b/iocore/net/QUICNetVConnection_quiche.cc index 7d4329f5fa1..c53f8412938 100644 --- a/iocore/net/QUICNetVConnection_quiche.cc +++ b/iocore/net/QUICNetVConnection_quiche.cc @@ -656,13 +656,32 @@ QUICNetVConnection::_handle_interval() int QUICNetVConnection::populate_protocol(std::string_view *results, int n) const { - return 0; + int retval = 0; + if (n > retval) { + results[retval++] = IP_PROTO_TAG_QUIC; + if (n > retval) { + results[retval++] = IP_PROTO_TAG_TLS_1_3; + if (n > retval) { + retval += super::populate_protocol(results + retval, n - retval); + } + } + } + return retval; } const char * -QUICNetVConnection::protocol_contains(std::string_view tag) const -{ - return ""; +QUICNetVConnection::protocol_contains(std::string_view prefix) const +{ + const char *retval = nullptr; + if (prefix.size() <= IP_PROTO_TAG_QUIC.size() && strncmp(IP_PROTO_TAG_QUIC.data(), prefix.data(), prefix.size()) == 0) { + retval = IP_PROTO_TAG_QUIC.data(); + } else if (prefix.size() <= IP_PROTO_TAG_TLS_1_3.size() && + strncmp(IP_PROTO_TAG_TLS_1_3.data(), prefix.data(), prefix.size()) == 0) { + retval = IP_PROTO_TAG_TLS_1_3.data(); + } else { + retval = super::protocol_contains(prefix); + } + return retval; } const char * diff --git a/proxy/http/HttpTransactHeaders.cc b/proxy/http/HttpTransactHeaders.cc index a2ba7b2d944..3b956e1e54a 100644 --- a/proxy/http/HttpTransactHeaders.cc +++ b/proxy/http/HttpTransactHeaders.cc @@ -707,8 +707,11 @@ HttpTransactHeaders::write_hdr_protocol_stack(char *hdr_string, size_t len, Prot if (ProtocolStackDetail::Standard == pSDetail) { *hdr++ = '/'; bool http_2_p = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_2_0) != proto_end; + bool http_3_p = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_3) != proto_end; if (http_2_p) { *hdr++ = '2'; + } else if (http_3_p) { + *hdr++ = '3'; } else if (http_1_0_p) { memcpy(hdr, "1.0", 3); hdr += 3; diff --git a/tests/gold_tests/headers/via.test.py b/tests/gold_tests/headers/via.test.py index 5be85ad1181..979d8c21b62 100644 --- a/tests/gold_tests/headers/via.test.py +++ b/tests/gold_tests/headers/via.test.py @@ -31,7 +31,12 @@ Test.ContinueOnFail = True # Define default ATS -ts = Test.MakeATSProcess("ts", enable_tls=True) +if Condition.HasATSFeature('TS_USE_QUIC') and Condition.HasCurlFeature('http3'): + ts = Test.MakeATSProcess("ts", enable_tls=True, enable_quic=True) +else: + ts = Test.MakeATSProcess("ts", enable_tls=True) + + server = Test.MakeOriginServer("server", options={'--load': os.path.join(Test.TestDirectory, 'via-observer.py')}) testName = "VIA" @@ -64,7 +69,10 @@ # Set up to check the output after the tests have run. via_log_id = Test.Disk.File("via.log") -via_log_id.Content = "via.gold" +if Condition.HasATSFeature('TS_USE_QUIC') and Condition.HasCurlFeature('http3'): + via_log_id.Content = "via_h3.gold" +else: + via_log_id.Content = "via.gold" # Basic HTTP 1.1 tr = Test.AddTestRun() @@ -91,13 +99,22 @@ # HTTP 2 tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --verbose --ipv4 --insecure --header "Host: www.example.com" https://localhost:{}'.format( +tr.Processes.Default.Command = 'curl --verbose --ipv4 --http2 --insecure --header "Host: www.example.com" https://localhost:{}'.format( ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts +# HTTP 3 +if Condition.HasATSFeature('TS_HAS_QUICHE') and Condition.HasCurlFeature('http3'): + tr = Test.AddTestRun() + tr.Processes.Default.Command = 'curl --verbose --ipv4 --http3 --insecure --header "Host: www.example.com" https://localhost:{}'.format( + ts.Variables.ssl_port) + tr.Processes.Default.ReturnCode = 0 + tr.StillRunningAfter = server + tr.StillRunningAfter = ts + # TLS tr = Test.AddTestRun() tr.Processes.Default.Command = 'curl --verbose --ipv4 --http1.1 --insecure --header "Host: www.example.com" https://localhost:{}'.format( diff --git a/tests/gold_tests/headers/via_h3.gold b/tests/gold_tests/headers/via_h3.gold new file mode 100644 index 00000000000..77aba364b0f --- /dev/null +++ b/tests/gold_tests/headers/via_h3.gold @@ -0,0 +1,7 @@ +Via: http/1.1 = http/1.1 tcp ipv4 +Via: http/1.0 = http/1.0 tcp ipv4 +Via: https/2 = http/1.1 h2 tls/1.{} tcp ipv4 +Via: https/3 = http/1.1 h3 quic tls/1.{} udp ipv4 +Via: https/1.1 = http/1.1 tls/1.{} tcp ipv4 +Via: http/1.1 = http/1.1 tcp ipv6 +Via: https/1.1 = http/1.1 tls/1.{} tcp ipv6