fix: fix issues
This commit is contained in:
18
apps/recorder/src/utils/http.rs
Normal file
18
apps/recorder/src/utils/http.rs
Normal 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}")),
|
||||
}
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
pub mod http;
|
||||
pub mod json;
|
||||
|
||||
Reference in New Issue
Block a user