fix: fix issues

This commit is contained in:
2025-06-17 02:23:02 +08:00
parent 721eee9c88
commit 35312ea1ff
15 changed files with 404 additions and 185 deletions

View File

@@ -0,0 +1,18 @@
use std::ops::Bound;
pub fn bound_range_to_content_range(
r: &(Bound<u64>, Bound<u64>),
l: u64,
) -> Result<String, String> {
match r {
(Bound::Included(start), Bound::Included(end)) => Ok(format!("bytes {start}-{end}/{l}")),
(Bound::Included(start), Bound::Excluded(end)) => {
Ok(format!("bytes {start}-{}/{l}", end - 1))
}
(Bound::Included(start), Bound::Unbounded) => Ok(format!(
"bytes {start}-{}/{l}",
if l > 0 { l - 1 } else { 0 }
)),
_ => Err(format!("bytes */{l}")),
}
}

View File

@@ -1 +1,2 @@
pub mod http;
pub mod json;