diff options
author | Josh Matthews <josh@joshmatthews.net> | 2025-01-08 00:47:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-08 05:47:58 +0000 |
commit | 76e0a1872baab22a4dfafcdaf431db4fe5864b18 (patch) | |
tree | 23119b8b3d8893f328efd492b804418c29ae080d /components/net/filemanager_thread.rs | |
parent | 270df6e26334149d12c975cb91e6db7e5fa8ccab (diff) | |
download | servo-76e0a1872baab22a4dfafcdaf431db4fe5864b18.tar.gz servo-76e0a1872baab22a4dfafcdaf431db4fe5864b18.zip |
Update all network-related dependencies to the latest versions (#34630)
* Update all network-related dependencies to the latest versions:
* rustls
* hyper
* http
* headers
* tungstenite
* async-tungstenite
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* net: Fix panics with 1xx responses in WPT tests.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* net: Use reported response length when calculating available ranges.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* net: Remove unreachable match arm.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* net: Clean up commented fragments in blob and file handlers.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* net: Remove unreachable match arm.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* net: Fix clippy warning.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* net: Cleanup.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* net: Fix up unit tests for dependency upgrades.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Update aws-lc-sys to fix Windows builds.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* net: Use ring instead of aws-lc-sys.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* embedding: Require embedder to initialize a rustls CryptoProvider.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Disable aws-lc-rs pending OhOS build fixes.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/net/filemanager_thread.rs')
-rw-r--r-- | components/net/filemanager_thread.rs | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/components/net/filemanager_thread.rs b/components/net/filemanager_thread.rs index 9ed08c9d85b..fa67529fe1d 100644 --- a/components/net/filemanager_thread.rs +++ b/components/net/filemanager_thread.rs @@ -11,7 +11,7 @@ use std::sync::atomic::{self, AtomicBool, AtomicUsize, Ordering}; use std::sync::{Arc, Mutex, RwLock, Weak}; use embedder_traits::{EmbedderMsg, EmbedderProxy, FilterPattern}; -use headers::{ContentLength, ContentType, HeaderMap, HeaderMapExt}; +use headers::{ContentLength, ContentType, HeaderMap, HeaderMapExt, Range}; use http::header::{self, HeaderValue}; use ipc_channel::ipc::{self, IpcSender}; use log::warn; @@ -30,6 +30,7 @@ use url::Url; use uuid::Uuid; use crate::fetch::methods::{CancellationListener, Data, RangeRequestBounds}; +use crate::protocols::get_range_request_bounds; use crate::resource_thread::CoreResourceThreadPool; pub const FILE_CHUNK_SIZE: usize = 32768; //32 KB @@ -132,7 +133,7 @@ impl FileManager { file_token: &FileTokenCheck, origin: FileOrigin, response: &mut Response, - range: RangeRequestBounds, + range: Option<Range>, ) -> Result<(), BlobURLStoreError> { self.fetch_blob_buf( done_sender, @@ -140,7 +141,7 @@ impl FileManager { &id, file_token, &origin, - range, + BlobBounds::Unresolved(range), response, ) } @@ -285,13 +286,17 @@ impl FileManager { id: &Uuid, file_token: &FileTokenCheck, origin_in: &FileOrigin, - range: RangeRequestBounds, + bounds: BlobBounds, response: &mut Response, ) -> Result<(), BlobURLStoreError> { let file_impl = self.store.get_impl(id, file_token, origin_in)?; match file_impl { FileImpl::Memory(buf) => { - let range = range + let bounds = match bounds { + BlobBounds::Unresolved(range) => get_range_request_bounds(range, buf.size), + BlobBounds::Resolved(bounds) => bounds, + }; + let range = bounds .get_final(Some(buf.size)) .map_err(|_| BlobURLStoreError::InvalidRange)?; @@ -323,7 +328,11 @@ impl FileManager { let file = File::open(&metadata.path) .map_err(|e| BlobURLStoreError::External(e.to_string()))?; - let range = range + let bounds = match bounds { + BlobBounds::Unresolved(range) => get_range_request_bounds(range, metadata.size), + BlobBounds::Resolved(bounds) => bounds, + }; + let range = bounds .get_final(Some(metadata.size)) .map_err(|_| BlobURLStoreError::InvalidRange)?; @@ -362,15 +371,16 @@ impl FileManager { FileImpl::Sliced(parent_id, inner_rel_pos) => { // Next time we don't need to check validity since // we have already done that for requesting URL if necessary. + let bounds = RangeRequestBounds::Final( + RelativePos::full_range().slice_inner(&inner_rel_pos), + ); self.fetch_blob_buf( done_sender, cancellation_listener, &parent_id, file_token, origin_in, - RangeRequestBounds::Final( - RelativePos::full_range().slice_inner(&inner_rel_pos), - ), + BlobBounds::Resolved(bounds), response, ) }, @@ -378,6 +388,11 @@ impl FileManager { } } +enum BlobBounds { + Unresolved(Option<Range>), + Resolved(RangeRequestBounds), +} + /// File manager's data store. It maintains a thread-safe mapping /// from FileID to FileStoreEntry which might have different backend implementation. /// Access to the content is encapsulated as methods of this struct. |