mirror of
https://github.com/denoland/deno.git
synced 2025-08-22 19:44:59 +00:00
refactor(ext/fetch): Remove FetchRequestBodyResource from FetchHandler interface (#20100)
This is unused and will allow us to remove `FetchRequestBodyResource` in a future PR.
This commit is contained in:
parent
03e963f578
commit
ddfcf1add4
2 changed files with 7 additions and 22 deletions
|
@ -3,7 +3,6 @@
|
||||||
use crate::CancelHandle;
|
use crate::CancelHandle;
|
||||||
use crate::CancelableResponseFuture;
|
use crate::CancelableResponseFuture;
|
||||||
use crate::FetchHandler;
|
use crate::FetchHandler;
|
||||||
use crate::FetchRequestBodyResource;
|
|
||||||
|
|
||||||
use deno_core::error::type_error;
|
use deno_core::error::type_error;
|
||||||
use deno_core::futures::FutureExt;
|
use deno_core::futures::FutureExt;
|
||||||
|
@ -25,11 +24,7 @@ impl FetchHandler for FsFetchHandler {
|
||||||
&self,
|
&self,
|
||||||
_state: &mut OpState,
|
_state: &mut OpState,
|
||||||
url: Url,
|
url: Url,
|
||||||
) -> (
|
) -> (CancelableResponseFuture, Option<Rc<CancelHandle>>) {
|
||||||
CancelableResponseFuture,
|
|
||||||
Option<FetchRequestBodyResource>,
|
|
||||||
Option<Rc<CancelHandle>>,
|
|
||||||
) {
|
|
||||||
let cancel_handle = CancelHandle::new_rc();
|
let cancel_handle = CancelHandle::new_rc();
|
||||||
let response_fut = async move {
|
let response_fut = async move {
|
||||||
let path = url.to_file_path()?;
|
let path = url.to_file_path()?;
|
||||||
|
@ -49,6 +44,6 @@ impl FetchHandler for FsFetchHandler {
|
||||||
.or_cancel(&cancel_handle)
|
.or_cancel(&cancel_handle)
|
||||||
.boxed_local();
|
.boxed_local();
|
||||||
|
|
||||||
(response_fut, None, Some(cancel_handle))
|
(response_fut, Some(cancel_handle))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,11 +142,7 @@ pub trait FetchHandler: dyn_clone::DynClone {
|
||||||
&self,
|
&self,
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
url: Url,
|
url: Url,
|
||||||
) -> (
|
) -> (CancelableResponseFuture, Option<Rc<CancelHandle>>);
|
||||||
CancelableResponseFuture,
|
|
||||||
Option<FetchRequestBodyResource>,
|
|
||||||
Option<Rc<CancelHandle>>,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dyn_clone::clone_trait_object!(FetchHandler);
|
dyn_clone::clone_trait_object!(FetchHandler);
|
||||||
|
@ -160,17 +156,13 @@ impl FetchHandler for DefaultFileFetchHandler {
|
||||||
&self,
|
&self,
|
||||||
_state: &mut OpState,
|
_state: &mut OpState,
|
||||||
_url: Url,
|
_url: Url,
|
||||||
) -> (
|
) -> (CancelableResponseFuture, Option<Rc<CancelHandle>>) {
|
||||||
CancelableResponseFuture,
|
|
||||||
Option<FetchRequestBodyResource>,
|
|
||||||
Option<Rc<CancelHandle>>,
|
|
||||||
) {
|
|
||||||
let fut = async move {
|
let fut = async move {
|
||||||
Ok(Err(type_error(
|
Ok(Err(type_error(
|
||||||
"NetworkError when attempting to fetch resource.",
|
"NetworkError when attempting to fetch resource.",
|
||||||
)))
|
)))
|
||||||
};
|
};
|
||||||
(Box::pin(fut), None, None)
|
(Box::pin(fut), None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,15 +258,13 @@ where
|
||||||
file_fetch_handler, ..
|
file_fetch_handler, ..
|
||||||
} = state.borrow_mut::<Options>();
|
} = state.borrow_mut::<Options>();
|
||||||
let file_fetch_handler = file_fetch_handler.clone();
|
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);
|
file_fetch_handler.fetch_file(state, url);
|
||||||
let request_rid = state.resource_table.add(FetchRequestResource(request));
|
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
|
let maybe_cancel_handle_rid = maybe_cancel_handle
|
||||||
.map(|ch| state.resource_table.add(FetchCancelHandle(ch)));
|
.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" => {
|
"http" | "https" => {
|
||||||
let permissions = state.borrow_mut::<FP>();
|
let permissions = state.borrow_mut::<FP>();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue