@tauri-apps/plugin-http 2.8.3 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-js/index.cjs +16 -11
- package/dist-js/index.js +16 -11
- package/package.json +1 -1
package/dist-js/index.cjs
CHANGED
|
@@ -77,7 +77,6 @@ async function fetch(input, init) {
|
|
|
77
77
|
: new Headers();
|
|
78
78
|
const req = new Request(input, init);
|
|
79
79
|
const buffer = await req.arrayBuffer();
|
|
80
|
-
const data = buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null;
|
|
81
80
|
// append new headers created by the browser `Request` implementation,
|
|
82
81
|
// if not already declared by the caller of this function
|
|
83
82
|
for (const [key, value] of req.headers) {
|
|
@@ -101,16 +100,18 @@ async function fetch(input, init) {
|
|
|
101
100
|
if (signal?.aborted) {
|
|
102
101
|
throw new Error(ERROR_REQUEST_CANCELLED);
|
|
103
102
|
}
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
103
|
+
const clientConfig = {
|
|
104
|
+
method: req.method,
|
|
105
|
+
url: req.url,
|
|
106
|
+
headers: mappedHeaders,
|
|
107
|
+
maxRedirections,
|
|
108
|
+
connectTimeout,
|
|
109
|
+
proxy,
|
|
110
|
+
danger
|
|
111
|
+
};
|
|
112
|
+
const rid = await core.invoke('plugin:http|fetch', new Uint8Array(buffer), {
|
|
113
|
+
headers: {
|
|
114
|
+
'client-config': encodeURIComponent(JSON.stringify(clientConfig))
|
|
114
115
|
}
|
|
115
116
|
});
|
|
116
117
|
const abort = () => core.invoke('plugin:http|fetch_cancel', { rid }).catch(() => { });
|
|
@@ -174,6 +175,10 @@ async function fetch(input, init) {
|
|
|
174
175
|
void dropBody();
|
|
175
176
|
}
|
|
176
177
|
});
|
|
178
|
+
if (body === null) {
|
|
179
|
+
// No stream will read or cancel this response's Rust resource.
|
|
180
|
+
await dropBody();
|
|
181
|
+
}
|
|
177
182
|
const res = new Response(body, {
|
|
178
183
|
status,
|
|
179
184
|
statusText
|
package/dist-js/index.js
CHANGED
|
@@ -75,7 +75,6 @@ async function fetch(input, init) {
|
|
|
75
75
|
: new Headers();
|
|
76
76
|
const req = new Request(input, init);
|
|
77
77
|
const buffer = await req.arrayBuffer();
|
|
78
|
-
const data = buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null;
|
|
79
78
|
// append new headers created by the browser `Request` implementation,
|
|
80
79
|
// if not already declared by the caller of this function
|
|
81
80
|
for (const [key, value] of req.headers) {
|
|
@@ -99,16 +98,18 @@ async function fetch(input, init) {
|
|
|
99
98
|
if (signal?.aborted) {
|
|
100
99
|
throw new Error(ERROR_REQUEST_CANCELLED);
|
|
101
100
|
}
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
const clientConfig = {
|
|
102
|
+
method: req.method,
|
|
103
|
+
url: req.url,
|
|
104
|
+
headers: mappedHeaders,
|
|
105
|
+
maxRedirections,
|
|
106
|
+
connectTimeout,
|
|
107
|
+
proxy,
|
|
108
|
+
danger
|
|
109
|
+
};
|
|
110
|
+
const rid = await invoke('plugin:http|fetch', new Uint8Array(buffer), {
|
|
111
|
+
headers: {
|
|
112
|
+
'client-config': encodeURIComponent(JSON.stringify(clientConfig))
|
|
112
113
|
}
|
|
113
114
|
});
|
|
114
115
|
const abort = () => invoke('plugin:http|fetch_cancel', { rid }).catch(() => { });
|
|
@@ -172,6 +173,10 @@ async function fetch(input, init) {
|
|
|
172
173
|
void dropBody();
|
|
173
174
|
}
|
|
174
175
|
});
|
|
176
|
+
if (body === null) {
|
|
177
|
+
// No stream will read or cancel this response's Rust resource.
|
|
178
|
+
await dropBody();
|
|
179
|
+
}
|
|
175
180
|
const res = new Response(body, {
|
|
176
181
|
status,
|
|
177
182
|
statusText
|