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:
@@ -26,9 +26,7 @@ use crate::auth::AuthenticatedUser;
|
||||
use crate::config::Config;
|
||||
use crate::error::AppError;
|
||||
use crate::magic_link::{MagicLinkStore, PendingMagicLink};
|
||||
use crate::web_session::{
|
||||
SessionStore, WebSession, build_session_cookie, generate_token,
|
||||
};
|
||||
use crate::web_session::{SessionStore, WebSession, build_session_cookie, generate_token};
|
||||
|
||||
/// Magic-link tokens only need to survive click → browser-launch → first
|
||||
/// request. 60s gives slow systems headroom without lengthening the attack
|
||||
@@ -58,7 +56,9 @@ pub async fn handle_create(
|
||||
body: Option<Json<MagicLinkRequest>>,
|
||||
) -> Result<Json<MagicLinkResponse>, AppError> {
|
||||
let req = body.map(|Json(r)| r).unwrap_or_default();
|
||||
let return_to = req.return_to.unwrap_or_else(|| DEFAULT_RETURN_TO.to_owned());
|
||||
let return_to = req
|
||||
.return_to
|
||||
.unwrap_or_else(|| DEFAULT_RETURN_TO.to_owned());
|
||||
|
||||
// Open-redirect guard: only accept paths under our own /web/ tree.
|
||||
// Reject schemes, hosts, protocol-relative URLs, and traversal.
|
||||
|
||||
Reference in New Issue
Block a user