fix: custom header is not applied when redirect-trailing-slash is disabled (#613)

It fixes an issue where custom headers were not applied for directory requests when the `redirect-trailing-slash` was disabled.
This commit is contained in:
Jose Quintana
2026-01-11 22:38:37 +01:00
committed by GitHub
parent 865e8e4e89
commit df5fb001e8

View File

@@ -24,21 +24,23 @@ pub(crate) fn post_process<T>(
advanced.headers.as_deref(),
&mut resp,
file_path,
opts.redirect_trailing_slash,
)
}
Ok(resp)
}
/// Append custom HTTP headers to current response.
pub fn append_headers(
fn append_headers(
uri_path: &str,
headers_opts: Option<&[Headers]>,
resp: &mut Response<Body>,
file_path: Option<&PathBuf>,
redirect_trailing_slash: bool,
) {
if let Some(headers_vec) = headers_opts {
let uri_path_auto_index = file_path
.filter(|_| uri_path.ends_with('/'))
.filter(|_| uri_path.ends_with('/') || !redirect_trailing_slash)
.and_then(|p| p.file_name())
.and_then(OsStr::to_str)
.map(|name| match uri_path {