v0.35.1: performance, AGPL licensing and documentation overhaul

- Web Server reads static files inline; proxy middleware chain flattened
- About window with license summary and project links; AGPL-3.0-or-later
- Rewritten documentation: feature list, screenshots, performance guide
- Fix false spikes in per-Vhost request-rate charts
This commit is contained in:
gru committed 2026-11-05 18:29:56 +01:00
1 parent d3b492874b
commit eba9f89283
135 files changed
+1425 -1064

No files matched your search

+1 -1
View File
@@ -64,7 +64,7 @@ async fn php_response_inner(
let mut response = builtin_error_response(StatusCode::SERVICE_UNAVAILABLE, &method);
response
.headers_mut()
.insert("retry-after", HeaderValue::from_static("1"));
.insert(::http::header::RETRY_AFTER, HeaderValue::from_static("1"));
return response;
}
};
+10
View File
@@ -177,6 +177,16 @@ async fn file_response_inner(
} else {
None
};
#[cfg(unix)]
if boundary.is_none() {
let stream = file_body::InlineFileStream::new(opened.file, start, body_length, stream_capacity);
*response.body_mut() = Body::new(file_body::FileBody::new(stream, body_length));
#[cfg(target_os = "linux")]
if let Some(candidate) = sendfile_candidate {
response.extensions_mut().insert(candidate);
}
return response;
}
let mut file = tokio::fs::File::from_std(opened.file);
if let Some(boundary) = boundary {
let ranges = ranges.expect("multipart ranges");
+59
View File
@@ -80,3 +80,62 @@ where
#[cfg(test)]
mod tests;
/// Reads a regular file in bounded chunks on the calling task.
#[cfg(unix)]
pub(super) struct InlineFileStream {
file: std::fs::File,
offset: u64,
remaining: u64,
chunk: usize,
}
#[cfg(unix)]
impl InlineFileStream {
pub(super) fn new(file: std::fs::File, offset: u64, length: u64, chunk: usize) -> Self {
Self {
file,
offset,
remaining: length,
chunk: chunk.max(1),
}
}
}
#[cfg(unix)]
impl Stream for InlineFileStream {
type Item = Result<Bytes, io::Error>;
fn poll_next(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
use std::os::unix::fs::FileExt;
let this = self.get_mut();
if this.remaining == 0 {
return Poll::Ready(None);
}
let want = this.remaining.min(this.chunk as u64) as usize;
let mut buffer = bytes::BytesMut::zeroed(want);
let mut filled = 0;
while filled < want {
match this
.file
.read_at(&mut buffer[filled..], this.offset + filled as u64)
{
Ok(0) => break,
Ok(read) => filled += read,
Err(error) if error.kind() == io::ErrorKind::Interrupted => {}
Err(error) => {
this.remaining = 0;
return Poll::Ready(Some(Err(error)));
}
}
}
if filled == 0 {
this.remaining = 0;
return Poll::Ready(None);
}
buffer.truncate(filled);
this.offset += filled as u64;
this.remaining -= filled as u64;
Poll::Ready(Some(Ok(buffer.freeze())))
}
}
+2 -3
View File
@@ -66,8 +66,7 @@ pub(super) fn builtin_error_response(status: StatusCode, method: &Method) -> Res
response
.headers_mut()
.insert(CACHE_CONTROL, HeaderValue::from_static("no-store"));
response.headers_mut().insert(
"x-content-type-options",
response.headers_mut().insert(::http::header::X_CONTENT_TYPE_OPTIONS,
HeaderValue::from_static("nosniff"),
);
response
@@ -249,7 +248,7 @@ fn add_download_header(response: &mut Response, service: &CompiledService, path:
pub(super) fn accepts_content_encoding(headers: &HeaderMap, wanted: &str) -> bool {
let Some(value) = headers
.get(http::header::ACCEPT_ENCODING)
.get(::http::header::ACCEPT_ENCODING)
.and_then(|value| value.to_str().ok())
else {
return false;
+2 -4
View File
@@ -13,9 +13,7 @@ pub(super) async fn open_components(
components: Vec<String>,
) -> io::Result<Opened> {
let root = FilesystemRoot::for_service(service);
tokio::task::spawn_blocking(move || secure_open_sync(&root, &components))
.await
.map_err(|_| io::Error::other("Web Server filesystem task failed"))?
secure_open_sync(&root, &components)
}
fn target_path_and_query(
@@ -129,7 +127,7 @@ pub(super) async fn select_precompressed(
return None;
}
if headers
.get("range")
.get(::http::header::RANGE)
.and_then(|value| value.to_str().ok())
.is_some_and(|value| value.contains(','))
{