@@ -22,6 +22,16 @@ pub const DEFAULT_HTTPS_PORT: NonZeroU16 = nonzero!(443u16);
2222pub struct HttpRouteFragment {
2323 pub host_header : Arc < str > ,
2424 pub path_prefix : Arc < str > ,
25+ /// If present, the connector may *assume* we'll be using this HTTP version.
26+ ///
27+ /// This isn't fully compliant with the H2 standard, RFC 7540; if we're using TLS, we should
28+ /// always check the ALPN result before going ahead with an H2 connection. However, at the time
29+ /// of this writing (Nov 2025) we don't connect to arbitrary servers with H2, only those we
30+ /// already know should support it. If we some day have a need to negotiate ALPN properly, we'll
31+ /// need to change [`TlsRouteFragment`] to accept multiple permitted ALPN values, and then once
32+ /// everything is threaded through we should be able to remove this field (treating "no ALPN" as
33+ /// "assume HTTP/1.1 only").
34+ pub http_version : Option < HttpVersion > ,
2535 /// Only for logging; the name of the domain front for this proxy.
2636 pub front_name : Option < & ' static str > ,
2737}
@@ -47,7 +57,7 @@ pub struct DomainFrontRouteProvider {
4757/// This is distinct from [`http::Version`] since only a subset of versions are
4858/// supported, and is distinct from [`Alpn`] which is TLS-specific and could in
4959/// theory represent non-HTTP-version values.
50- #[ derive( Copy , Clone , Debug ) ]
60+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
5161pub enum HttpVersion {
5262 Http1_1 ,
5363 Http2 ,
@@ -141,6 +151,7 @@ impl RouteProvider for DomainFrontRouteProvider {
141151 fragment : HttpRouteFragment {
142152 host_header : Arc :: clone ( http_host) ,
143153 path_prefix : Arc :: clone ( path_prefix) ,
154+ http_version : Some ( * http_version) ,
144155 front_name : Some ( * front_name) ,
145156 } ,
146157 } )
@@ -175,6 +186,7 @@ where
175186 fragment : HttpRouteFragment {
176187 host_header : Arc :: clone ( direct_host_header) ,
177188 path_prefix : "" . into ( ) ,
189+ http_version : Some ( * direct_http_version) ,
178190 front_name : None ,
179191 } ,
180192 inner,
@@ -260,6 +272,7 @@ mod test {
260272 fragment: HttpRouteFragment {
261273 host_header: "direct-host" . into( ) ,
262274 path_prefix: "" . into( ) ,
275+ http_version: Some ( HttpVersion :: Http2 ) ,
263276 front_name: None ,
264277 } ,
265278 inner: TlsRoute {
@@ -279,6 +292,7 @@ mod test {
279292 fragment: HttpRouteFragment {
280293 host_header: "front-host-1" . into( ) ,
281294 path_prefix: "/prefix-1" . into( ) ,
295+ http_version: Some ( HttpVersion :: Http1_1 ) ,
282296 front_name: Some ( "front-1" )
283297 } ,
284298 inner: TlsRoute {
@@ -298,6 +312,7 @@ mod test {
298312 fragment: HttpRouteFragment {
299313 host_header: "front-host-1" . into( ) ,
300314 path_prefix: "/prefix-1" . into( ) ,
315+ http_version: Some ( HttpVersion :: Http1_1 ) ,
301316 front_name: Some ( "front-1" )
302317 } ,
303318 inner: TlsRoute {
@@ -317,6 +332,7 @@ mod test {
317332 fragment: HttpRouteFragment {
318333 host_header: "front-host-2" . into( ) ,
319334 path_prefix: "/prefix-2" . into( ) ,
335+ http_version: Some ( HttpVersion :: Http1_1 ) ,
320336 front_name: Some ( "front-2" )
321337 } ,
322338 inner: TlsRoute {
0 commit comments