mirror of
https://github.com/static-web-server/static-web-server.git
synced 2026-01-25 05:06:33 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user