fix(core): parse range bytes=0-*, closes #3143 (#3516)

This commit is contained in:
Lucas Fernandes Nogueira
2022-02-24 10:05:50 -03:00
committed by GitHub
parent fb6744daa4
commit d06efc7704
2 changed files with 14 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"tauri": patch
---
Allow range in the form of `bytes=0-*` on the asset protocol.

View File

@@ -558,11 +558,18 @@ impl<R: Runtime> WindowManager<R> {
}
};
// parse the range
let range = match crate::runtime::http::HttpRange::parse(&range, file_size) {
let range = match crate::runtime::http::HttpRange::parse(
&if range.ends_with("-*") {
range.chars().take(range.len() - 1).collect::<String>()
} else {
range.clone()
},
file_size,
) {
Ok(r) => r,
Err(e) => {
#[cfg(debug_assertions)]
eprintln!("Failed to parse range: {:?}", e);
eprintln!("Failed to parse range {}: {:?}", range, e);
return (headers, 400, buf);
}
};