fix: fix http plugin fetch init with connectTimeout. (#858)

pull/867/head
hygkui 1 year ago committed by GitHub
parent e80626cf81
commit 1a347203a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
"http-js": minor
---
Fix http fetch client option init with parameter `connectTimeout`

@ -103,7 +103,7 @@ export async function fetch(
init?: RequestInit & ClientOptions,
): Promise<Response> {
const maxRedirections = init?.maxRedirections;
const connectTimeout = init?.maxRedirections;
const connectTimeout = init?.connectTimeout;
const proxy = init?.proxy;
// Remove these fields before creating the request

@ -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__})}

Loading…
Cancel
Save