This commit is contained in:
Mateusz Gruszczyński committed 2026-10-19 14:05:13 +02:00
1 parent 28e39f7ce4
commit b57beb83c7
34 files changed
+1037 -314

No files matched your search

+18 -14
View File
@@ -347,20 +347,19 @@ async fn serve_inner(
}
let root = FilesystemRoot::for_service(service);
let components_for_list = components.clone();
let mut entries = match tokio::task::spawn_blocking(move || {
list_directory_sync(&root, &components_for_list)
})
.await
{
Ok(Ok(entries)) => entries,
Ok(Err(error)) => return io_response(&error),
Err(_) => {
return status_response(
StatusCode::INTERNAL_SERVER_ERROR,
"RustProxy: Web Server directory task failed\n",
)
}
};
let mut entries =
match tokio::task::spawn_blocking(move || list_directory_sync(&root, &components_for_list))
.await
{
Ok(Ok(entries)) => entries,
Ok(Err(error)) => return io_response(&error),
Err(_) => {
return status_response(
StatusCode::INTERNAL_SERVER_ERROR,
"RustProxy: Web Server directory task failed\n",
)
}
};
// Filtering in place avoids a second Vec allocation for large directories
// while retaining exactly the same visibility and hardening checks.
entries.retain(|entry| {
@@ -419,6 +418,11 @@ pub async fn serve(
crate::web_server::metrics::HeadersInFlight::new(&service.web_metrics.in_flight_headers);
let request_method = method.clone();
let mut response = serve_inner(service, method, headers, uri, path, body, context).await;
// HEAD carries the same metadata/status as GET, but no response body,
// including the generic filesystem and rewrite error paths.
if request_method == Method::HEAD {
*response.body_mut() = Body::empty();
}
add_service_headers(&mut response, service);
htaccess::apply_response(service.htaccess.as_ref(), &mut response, path);
strip_unnecessary_headers(&mut response, service);