Add Content Range Header and add one for blob end range (#34797)

Signed-off-by: rayguo17 <rayguo17@gmail.com>
This commit is contained in:
TIN TUN AUNG 2025-01-14 08:21:29 +08:00 committed by GitHub
parent faf30176f1
commit 55ac1887dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 75 additions and 95 deletions

View file

@ -109,6 +109,16 @@ impl RelativePos {
end: (start + span).to_usize().unwrap(),
}
}
// Per <https://fetch.spec.whatwg.org/#concept-scheme-fetch> step 3.blob.14.8:
// "A range header denotes an inclusive byte range, while the slice blob algorithm input range does not.
// To use the slice blob algorithm, we have to increment rangeEnd."
pub fn to_abs_blob_range(&self, size: usize) -> Range<usize> {
let orig_range = self.to_abs_range(size);
let start = orig_range.start;
let end = usize::min(orig_range.end + 1, size);
Range { start, end }
}
}
/// Response to file selection request