This commit is contained in:
Mateusz Gruszczyński committed 2026-10-31 23:42:58 +01:00
1 parent 2c03fcf248
commit d3b492874b
95 files changed
+1628 -743

No files matched your search

+1 -1
View File
@@ -251,7 +251,7 @@ impl Drop for Exchange {
sni: None,
authority: None,
matched_by: None,
cache_reason: *self
cache_reason: self
.cache_reason
.get_mut()
.unwrap_or_else(|e| e.into_inner()),
+1
View File
@@ -86,6 +86,7 @@ enum ErrorFallbackBody {
const MAX_ERROR_FALLBACK_DEPTH: u8 = 8;
const MAX_ERROR_FALLBACK_REPLAY_BODY_BYTES: u64 = 8 * 1024 * 1024;
#[allow(clippy::result_large_err)]
async fn prepare_error_fallback_body(
request: &mut Request,
enabled: bool,
+1 -1
View File
@@ -912,7 +912,7 @@ mod cache_fast_path_tests {
assert_eq!(origin.requests.load(Ordering::Relaxed), 2);
fixture.stop().await;
let origin = origin().await;
let origin = self::origin().await;
let mut config = config_for(origin.addr, true);
config.cache.default_ttl_seconds = 45;
let fixture = Fixture::new(config).await;
+2 -2
View File
@@ -208,7 +208,7 @@ let upstream_result = loop {
let selection = match pool
.select_retry_wait(
context.client_ip,
&retry_headers,
retry_headers,
tls,
&attempted_backends,
)
@@ -232,7 +232,7 @@ let upstream_result = loop {
let Some(next_request) = retry_request(
&retry_method,
upstream_request_version(&next_backend, false),
&retry_headers,
retry_headers,
&next_backend,
&original_host,
&origin_suffix,
+50 -2
View File
@@ -45,7 +45,12 @@ mod authority_tests {
.extensions_mut()
.insert(LocalAddr("127.0.0.1:8080".parse().unwrap()));
assert!(response_context(&snapshot, &invalid).validated.is_none());
assert!(crate::acl::routing_path_view("/encoded%2fslash").is_err());
assert_eq!(
crate::acl::routing_path_view("/encoded%2fslash")
.unwrap()
.as_ref(),
"/encoded/slash"
);
}
#[test]
@@ -477,6 +482,39 @@ mod authority_tests {
);
}
#[test]
fn encoded_slash_routes_on_normalized_path_but_preserves_upstream_target() {
let config = crate::config::demo_config("127.0.0.1:9000".parse().unwrap());
let snapshot = crate::config::compile(config, 1, &validation_policy()).unwrap();
for suffix in ["/a%2Fb?x=1", "/a%2fb?x=1"] {
let mut request = Request::builder()
.method(Method::GET)
.uri(suffix)
.header(HOST, "localhost")
.body(Body::empty())
.unwrap();
request
.extensions_mut()
.insert(LocalAddr("127.0.0.1:8080".parse().unwrap()));
let context = response_context(&snapshot, &request);
let route = context.route.as_ref().expect("route selected");
let routing_path = context
.validated
.as_ref()
.and_then(|validated| validated.decoded_path.as_deref())
.expect("encoded slash creates a normalized routing path");
assert_eq!(routing_path, "/a/b");
assert!(route.rewritten_path(routing_path).unwrap().is_none());
let public_suffix = request.uri().path_and_query().unwrap().as_str();
assert_eq!(public_suffix, suffix);
let backend = route.backend.as_ref().expect("reverse-proxy backend");
let upstream = upstream_uri(backend, public_suffix).unwrap();
assert_eq!(upstream.path_and_query().unwrap().as_str(), suffix);
}
}
#[test]
fn upstream_uri_preserves_nested_url_query_without_rejecting_valid_separators() {
let config = crate::config::demo_config("127.0.0.1:9000".parse().unwrap());
@@ -670,6 +708,16 @@ mod graceful_h2_tests {
use super::*;
use std::fmt;
fn validation_policy() -> crate::config::ValidationPolicy {
crate::config::ValidationPolicy {
tls_addr: None,
cert_dir: None,
data_dir: None,
proxy_addr: "127.0.0.1:8080".parse().unwrap(),
admin_addr: "127.0.0.1:9090".parse().unwrap(),
}
}
#[derive(Debug)]
struct H2DebugError(&'static str);
impl fmt::Display for H2DebugError {
@@ -697,7 +745,7 @@ mod graceful_h2_tests {
let backend = &snapshot.pools[0].members[0].backend;
assert_eq!(
backend.request_origin_uri.to_string(),
backend.request_origin
format!("{}/", backend.request_origin)
);
for suffix in [
"/",
+10 -13
View File
@@ -10,19 +10,16 @@ struct SelectedRouteContext {
route: Option<Arc<crate::config::CompiledRoute>>,
validated: Option<ValidatedRoutingIdentity>,
}
fn take_routing_identity(
request: &mut Request,
tls: bool,
) -> Result<
(
Option<SelectedRouteContext>,
HeaderValue,
String,
Option<String>,
bool,
),
Response,
> {
type RoutingIdentity = (
Option<SelectedRouteContext>,
HeaderValue,
String,
Option<String>,
bool,
);
#[allow(clippy::result_large_err)]
fn take_routing_identity(request: &mut Request, tls: bool) -> Result<RoutingIdentity, Response> {
let mut selected_context = request.extensions_mut().remove::<SelectedRouteContext>();
let validated = selected_context
.as_mut()
+1 -1
View File
@@ -228,7 +228,7 @@ async fn observe(State(state): State<Arc<App>>, mut request: Request, next: Next
.map(|context| context.0.clone());
let effective_route_context = final_route_context
.as_deref()
.or_else(|| route_context.as_deref());
.or(route_context.as_deref());
let minimal_welcome = response
.extensions()
.get::<crate::pages::MinimalWelcome>()