diff options
author | TIN TUN AUNG <62133983+rayguo17@users.noreply.github.com> | 2025-01-14 08:21:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-14 00:21:29 +0000 |
commit | 55ac1887dc57f5b7924059ed57612338a2c7bf51 (patch) | |
tree | f4c9a466340a7aa37ea63db4db17d0d43665daeb /components/shared/net/filemanager_thread.rs | |
parent | faf30176f18e276125cbdac4a5750834258460c5 (diff) | |
download | servo-55ac1887dc57f5b7924059ed57612338a2c7bf51.tar.gz servo-55ac1887dc57f5b7924059ed57612338a2c7bf51.zip |
Add Content Range Header and add one for blob end range (#34797)
Signed-off-by: rayguo17 <rayguo17@gmail.com>
Diffstat (limited to 'components/shared/net/filemanager_thread.rs')
-rw-r--r-- | components/shared/net/filemanager_thread.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/components/shared/net/filemanager_thread.rs b/components/shared/net/filemanager_thread.rs index c6d0dde7ecb..5167ab1b4de 100644 --- a/components/shared/net/filemanager_thread.rs +++ b/components/shared/net/filemanager_thread.rs @@ -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 |