From ddfcf1add462b200e8cf738ffc25d9fa1e98c9dc Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Wed, 9 Aug 2023 10:47:47 -0600 Subject: [PATCH] refactor(ext/fetch): Remove FetchRequestBodyResource from FetchHandler interface (#20100) This is unused and will allow us to remove `FetchRequestBodyResource` in a future PR. --- ext/fetch/fs_fetch_handler.rs | 9 ++------- ext/fetch/lib.rs | 20 +++++--------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/ext/fetch/fs_fetch_handler.rs b/ext/fetch/fs_fetch_handler.rs index 0a83faaa1d..83880c4ca2 100644 --- a/ext/fetch/fs_fetch_handler.rs +++ b/ext/fetch/fs_fetch_handler.rs @@ -3,7 +3,6 @@ use crate::CancelHandle; use crate::CancelableResponseFuture; use crate::FetchHandler; -use crate::FetchRequestBodyResource; use deno_core::error::type_error; use deno_core::futures::FutureExt; @@ -25,11 +24,7 @@ impl FetchHandler for FsFetchHandler { &self, _state: &mut OpState, url: Url, - ) -> ( - CancelableResponseFuture, - Option, - Option>, - ) { + ) -> (CancelableResponseFuture, Option>) { let cancel_handle = CancelHandle::new_rc(); let response_fut = async move { let path = url.to_file_path()?; @@ -49,6 +44,6 @@ impl FetchHandler for FsFetchHandler { .or_cancel(&cancel_handle) .boxed_local(); - (response_fut, None, Some(cancel_handle)) + (response_fut, Some(cancel_handle)) } } diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs index b2b71ec56d..dd83f19eeb 100644 --- a/ext/fetch/lib.rs +++ b/ext/fetch/lib.rs @@ -142,11 +142,7 @@ pub trait FetchHandler: dyn_clone::DynClone { &self, state: &mut OpState, url: Url, - ) -> ( - CancelableResponseFuture, - Option, - Option>, - ); + ) -> (CancelableResponseFuture, Option>); } dyn_clone::clone_trait_object!(FetchHandler); @@ -160,17 +156,13 @@ impl FetchHandler for DefaultFileFetchHandler { &self, _state: &mut OpState, _url: Url, - ) -> ( - CancelableResponseFuture, - Option, - Option>, - ) { + ) -> (CancelableResponseFuture, Option>) { let fut = async move { Ok(Err(type_error( "NetworkError when attempting to fetch resource.", ))) }; - (Box::pin(fut), None, None) + (Box::pin(fut), None) } } @@ -266,15 +258,13 @@ where file_fetch_handler, .. } = state.borrow_mut::(); let file_fetch_handler = file_fetch_handler.clone(); - let (request, maybe_request_body, maybe_cancel_handle) = + let (request, maybe_cancel_handle) = file_fetch_handler.fetch_file(state, url); let request_rid = state.resource_table.add(FetchRequestResource(request)); - let maybe_request_body_rid = - maybe_request_body.map(|r| state.resource_table.add(r)); let maybe_cancel_handle_rid = maybe_cancel_handle .map(|ch| state.resource_table.add(FetchCancelHandle(ch))); - (request_rid, maybe_request_body_rid, maybe_cancel_handle_rid) + (request_rid, None, maybe_cancel_handle_rid) } "http" | "https" => { let permissions = state.borrow_mut::();