Skip to content

Commit 477582f

Browse files
authored
Fix protocol version in request Via header (#9716)
* Fix protocol version in request Via header * Add a test case for H3 to autest for Via header * Fix gold file for h3
1 parent 6b84d6d commit 477582f

4 files changed

Lines changed: 53 additions & 7 deletions

File tree

iocore/net/QUICNetVConnection_quiche.cc

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,13 +656,32 @@ QUICNetVConnection::_handle_interval()
656656
int
657657
QUICNetVConnection::populate_protocol(std::string_view *results, int n) const
658658
{
659-
return 0;
659+
int retval = 0;
660+
if (n > retval) {
661+
results[retval++] = IP_PROTO_TAG_QUIC;
662+
if (n > retval) {
663+
results[retval++] = IP_PROTO_TAG_TLS_1_3;
664+
if (n > retval) {
665+
retval += super::populate_protocol(results + retval, n - retval);
666+
}
667+
}
668+
}
669+
return retval;
660670
}
661671

662672
const char *
663-
QUICNetVConnection::protocol_contains(std::string_view tag) const
664-
{
665-
return "";
673+
QUICNetVConnection::protocol_contains(std::string_view prefix) const
674+
{
675+
const char *retval = nullptr;
676+
if (prefix.size() <= IP_PROTO_TAG_QUIC.size() && strncmp(IP_PROTO_TAG_QUIC.data(), prefix.data(), prefix.size()) == 0) {
677+
retval = IP_PROTO_TAG_QUIC.data();
678+
} else if (prefix.size() <= IP_PROTO_TAG_TLS_1_3.size() &&
679+
strncmp(IP_PROTO_TAG_TLS_1_3.data(), prefix.data(), prefix.size()) == 0) {
680+
retval = IP_PROTO_TAG_TLS_1_3.data();
681+
} else {
682+
retval = super::protocol_contains(prefix);
683+
}
684+
return retval;
666685
}
667686

668687
const char *

proxy/http/HttpTransactHeaders.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,11 @@ HttpTransactHeaders::write_hdr_protocol_stack(char *hdr_string, size_t len, Prot
707707
if (ProtocolStackDetail::Standard == pSDetail) {
708708
*hdr++ = '/';
709709
bool http_2_p = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_2_0) != proto_end;
710+
bool http_3_p = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_3) != proto_end;
710711
if (http_2_p) {
711712
*hdr++ = '2';
713+
} else if (http_3_p) {
714+
*hdr++ = '3';
712715
} else if (http_1_0_p) {
713716
memcpy(hdr, "1.0", 3);
714717
hdr += 3;

tests/gold_tests/headers/via.test.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
Test.ContinueOnFail = True
3232

3333
# Define default ATS
34-
ts = Test.MakeATSProcess("ts", enable_tls=True)
34+
if Condition.HasATSFeature('TS_USE_QUIC') and Condition.HasCurlFeature('http3'):
35+
ts = Test.MakeATSProcess("ts", enable_tls=True, enable_quic=True)
36+
else:
37+
ts = Test.MakeATSProcess("ts", enable_tls=True)
38+
39+
3540
server = Test.MakeOriginServer("server", options={'--load': os.path.join(Test.TestDirectory, 'via-observer.py')})
3641

3742
testName = "VIA"
@@ -64,7 +69,10 @@
6469

6570
# Set up to check the output after the tests have run.
6671
via_log_id = Test.Disk.File("via.log")
67-
via_log_id.Content = "via.gold"
72+
if Condition.HasATSFeature('TS_USE_QUIC') and Condition.HasCurlFeature('http3'):
73+
via_log_id.Content = "via_h3.gold"
74+
else:
75+
via_log_id.Content = "via.gold"
6876

6977
# Basic HTTP 1.1
7078
tr = Test.AddTestRun()
@@ -91,13 +99,22 @@
9199

92100
# HTTP 2
93101
tr = Test.AddTestRun()
94-
tr.Processes.Default.Command = 'curl --verbose --ipv4 --insecure --header "Host: www.example.com" https://localhost:{}'.format(
102+
tr.Processes.Default.Command = 'curl --verbose --ipv4 --http2 --insecure --header "Host: www.example.com" https://localhost:{}'.format(
95103
ts.Variables.ssl_port)
96104
tr.Processes.Default.ReturnCode = 0
97105

98106
tr.StillRunningAfter = server
99107
tr.StillRunningAfter = ts
100108

109+
# HTTP 3
110+
if Condition.HasATSFeature('TS_HAS_QUICHE') and Condition.HasCurlFeature('http3'):
111+
tr = Test.AddTestRun()
112+
tr.Processes.Default.Command = 'curl --verbose --ipv4 --http3 --insecure --header "Host: www.example.com" https://localhost:{}'.format(
113+
ts.Variables.ssl_port)
114+
tr.Processes.Default.ReturnCode = 0
115+
tr.StillRunningAfter = server
116+
tr.StillRunningAfter = ts
117+
101118
# TLS
102119
tr = Test.AddTestRun()
103120
tr.Processes.Default.Command = 'curl --verbose --ipv4 --http1.1 --insecure --header "Host: www.example.com" https://localhost:{}'.format(
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Via: http/1.1 = http/1.1 tcp ipv4
2+
Via: http/1.0 = http/1.0 tcp ipv4
3+
Via: https/2 = http/1.1 h2 tls/1.{} tcp ipv4
4+
Via: https/3 = http/1.1 h3 quic tls/1.{} udp ipv4
5+
Via: https/1.1 = http/1.1 tls/1.{} tcp ipv4
6+
Via: http/1.1 = http/1.1 tcp ipv6
7+
Via: https/1.1 = http/1.1 tls/1.{} tcp ipv6

0 commit comments

Comments
 (0)