Implement audio range requests

This commit enables serving audio files via HTTP Range requests. This is
crucial for allowing HTML5 audio players to seek to specific positions
within an audio file without re-downloading the entire file.

The changes include:
- Modifying `handle_audio` in `server/src/routes/web.rs` to parse
  `Range` headers.
- Implementing `serve_range` to handle partial content responses.
- Adding a `parse_range` helper function.
- Updating tests to verify range request functionality.
- Adding `ACCEPT_RANGES: bytes` header to indicate support for range
  requests.
- Storing recording duration in a sidecar file for faster UI rendering.
- Enhancing the HTML template to support a custom audio player with
  seeking.
This commit is contained in:
2026-04-19 22:26:04 +02:00
parent 2bcdb5436e
commit 17aa5d7200
9 changed files with 665 additions and 48 deletions
+5 -6
View File
@@ -90,10 +90,7 @@ async fn create_without_api_key_returns_401() {
let (state, _) = build_state();
let app = doctate_server::create_router_with_state(state);
let resp = app
.oneshot(create_request("{}", None))
.await
.unwrap();
let resp = app.oneshot(create_request("{}", None)).await.unwrap();
assert_eq!(resp.status(), StatusCode::UNAUTHORIZED);
}
@@ -193,7 +190,10 @@ async fn consume_token_is_one_time_use() {
let second = app.oneshot(consume_request(&token)).await.unwrap();
// Second use: token gone, redirect to login.
assert_eq!(second.status(), StatusCode::SEE_OTHER);
assert_eq!(second.headers().get(header::LOCATION).unwrap(), "/web/login");
assert_eq!(
second.headers().get(header::LOCATION).unwrap(),
"/web/login"
);
}
#[tokio::test]
@@ -249,4 +249,3 @@ async fn consume_expired_token_redirects_to_login() {
// And the token must be removed from the store, even though it expired.
assert!(store.read().await.get(&token).is_none());
}