feat(http): improve performance (#558)

This commit is contained in:
Lucas Fernandes Nogueira
2023-08-14 15:53:55 -07:00
committed by GitHub
parent 12adc1dbec
commit aec17a90fc
2 changed files with 7 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"http": patch
---
Improve response performance by using the new IPC streaming data.
+2 -3
View File
@@ -163,16 +163,15 @@ pub async fn fetch_send<R: Runtime>(
})
}
// TODO: change return value to tauri::ipc::Response on next alpha
#[command]
pub(crate) async fn fetch_read_body<R: Runtime>(
app: AppHandle<R>,
rid: RequestId,
) -> crate::Result<Vec<u8>> {
) -> crate::Result<tauri::ipc::Response> {
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()))
}