diff --git a/.changes/http-stream-support.md b/.changes/http-stream-support.md new file mode 100644 index 00000000..d9e38a6b --- /dev/null +++ b/.changes/http-stream-support.md @@ -0,0 +1,6 @@ +--- +"http": minor +"http-js": minor +--- + +Add stream support for HTTP stream responses. diff --git a/plugins/http/guest-js/index.ts b/plugins/http/guest-js/index.ts index d0e14d42..2d86e9d8 100644 --- a/plugins/http/guest-js/index.ts +++ b/plugins/http/guest-js/index.ts @@ -200,9 +200,9 @@ export async function fetch( // close when the signal to close (an empty chunk) // is sent from the IPC. - if (res instanceof ArrayBuffer - ? res.byteLength == 0 - : res.length == 0) { + if ( + res instanceof ArrayBuffer ? res.byteLength == 0 : res.length == 0 + ) { controller.close() return } diff --git a/plugins/http/src/commands.rs b/plugins/http/src/commands.rs index 687cb8f2..17e514e2 100644 --- a/plugins/http/src/commands.rs +++ b/plugins/http/src/commands.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT - use std::{future::Future, pin::Pin, str::FromStr, sync::Arc, time::Duration}; use http::{header, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; @@ -179,7 +178,7 @@ pub async fn fetch( client_config: ClientConfig, command_scope: CommandScope, global_scope: GlobalScope, - stream_channel: Channel + stream_channel: Channel, ) -> crate::Result { let ClientConfig { method, @@ -328,7 +327,6 @@ pub async fn fetch( Ok(res) }; - let mut resources_table = webview.resources_table(); let rid = resources_table.add_request(Box::pin(fut));