diff --git a/.changes/http-init-fetch-option-connectTimeout.md b/.changes/http-init-fetch-option-connectTimeout.md new file mode 100644 index 00000000..d9dda93f --- /dev/null +++ b/.changes/http-init-fetch-option-connectTimeout.md @@ -0,0 +1,5 @@ +--- +"http-js": minor +--- + +Fix http fetch client option init with parameter `connectTimeout` \ No newline at end of file diff --git a/plugins/http/guest-js/index.ts b/plugins/http/guest-js/index.ts index f40ddea0..17dd5703 100644 --- a/plugins/http/guest-js/index.ts +++ b/plugins/http/guest-js/index.ts @@ -103,7 +103,7 @@ export async function fetch( init?: RequestInit & ClientOptions, ): Promise { const maxRedirections = init?.maxRedirections; - const connectTimeout = init?.maxRedirections; + const connectTimeout = init?.connectTimeout; const proxy = init?.proxy; // Remove these fields before creating the request diff --git a/plugins/http/src/api-iife.js b/plugins/http/src/api-iife.js index b37e5c08..54f9cd6c 100644 --- a/plugins/http/src/api-iife.js +++ b/plugins/http/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_PLUGIN_HTTP__=function(e){"use strict";async function t(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}return"function"==typeof SuppressedError&&SuppressedError,e.fetch=async function(e,r){const n=r?.maxRedirections,i=r?.maxRedirections,a=r?.proxy;r&&(delete r.maxRedirections,delete r.connectTimeout,delete r.proxy);const o=new Request(e,r),s=await o.arrayBuffer(),d=s.byteLength?Array.from(new Uint8Array(s)):null,u=await t("plugin:http|fetch",{clientConfig:{method:o.method,url:o.url,headers:Array.from(o.headers.entries()),data:d,maxRedirections:n,connectTimeout:i,proxy:a}});o.signal.addEventListener("abort",(()=>{t("plugin:http|fetch_cancel",{rid:u})}));const{status:_,statusText:c,url:p,headers:f}=await t("plugin:http|fetch_send",{rid:u}),l=await t("plugin:http|fetch_read_body",{rid:u}),h=new Response(new Uint8Array(l),{headers:f,status:_,statusText:c});return Object.defineProperty(h,"url",{value:p}),h},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})} +if("__TAURI__"in window){var __TAURI_PLUGIN_HTTP__=function(e){"use strict";async function t(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}return"function"==typeof SuppressedError&&SuppressedError,e.fetch=async function(e,r){const n=r?.maxRedirections,i=r?.connectTimeout,a=r?.proxy;r&&(delete r.maxRedirections,delete r.connectTimeout,delete r.proxy);const o=new Request(e,r),s=await o.arrayBuffer(),u=s.byteLength?Array.from(new Uint8Array(s)):null,c=await t("plugin:http|fetch",{clientConfig:{method:o.method,url:o.url,headers:Array.from(o.headers.entries()),data:u,maxRedirections:n,connectTimeout:i,proxy:a}});o.signal.addEventListener("abort",(()=>{t("plugin:http|fetch_cancel",{rid:c})}));const{status:_,statusText:d,url:p,headers:f}=await t("plugin:http|fetch_send",{rid:c}),l=await t("plugin:http|fetch_read_body",{rid:c}),h=new Response(new Uint8Array(l),{headers:f,status:_,statusText:d});return Object.defineProperty(h,"url",{value:p}),h},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})}