From aec17a90fc365774c70c4876b94a899416120e26 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Mon, 14 Aug 2023 15:53:55 -0700 Subject: [PATCH] feat(http): improve performance (#558) --- .changes/http-response.md | 5 +++++ plugins/http/src/commands.rs | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 .changes/http-response.md diff --git a/.changes/http-response.md b/.changes/http-response.md new file mode 100644 index 00000000..4be8f924 --- /dev/null +++ b/.changes/http-response.md @@ -0,0 +1,5 @@ +--- +"http": patch +--- + +Improve response performance by using the new IPC streaming data. diff --git a/plugins/http/src/commands.rs b/plugins/http/src/commands.rs index 833b4e7f..898b180e 100644 --- a/plugins/http/src/commands.rs +++ b/plugins/http/src/commands.rs @@ -163,16 +163,15 @@ pub async fn fetch_send( }) } -// TODO: change return value to tauri::ipc::Response on next alpha #[command] pub(crate) async fn fetch_read_body( app: AppHandle, rid: RequestId, -) -> crate::Result> { +) -> crate::Result { let mut response_table = app.http().responses.lock().await; let res = response_table .remove(&rid) .ok_or(Error::InvalidRequestId(rid))?; - Ok(res.bytes().await?.to_vec()) + Ok(tauri::ipc::Response::new(res.bytes().await?.to_vec())) }