@tauri-apps/plugin-http 2.0.0-alpha.6 → 2.0.0-beta.1
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/README.md +2 -2
- package/dist-js/index.cjs +10 -5
- package/dist-js/index.js +10 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Access the HTTP client written in Rust.
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
_This plugin requires a Rust version of at least **1.
|
|
7
|
+
_This plugin requires a Rust version of at least **1.75**_
|
|
8
8
|
|
|
9
9
|
There are three general methods of installation that we can recommend.
|
|
10
10
|
|
|
@@ -18,7 +18,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file:
|
|
|
18
18
|
|
|
19
19
|
```toml
|
|
20
20
|
[dependencies]
|
|
21
|
-
tauri-plugin-http = "2.0.0-
|
|
21
|
+
tauri-plugin-http = "2.0.0-beta"
|
|
22
22
|
# alternatively with Git:
|
|
23
23
|
tauri-plugin-http = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
|
24
24
|
```
|
package/dist-js/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var core = require('@tauri-apps/api/core');
|
|
|
42
42
|
*/
|
|
43
43
|
async function fetch(input, init) {
|
|
44
44
|
const maxRedirections = init?.maxRedirections;
|
|
45
|
-
const connectTimeout = init?.
|
|
45
|
+
const connectTimeout = init?.connectTimeout;
|
|
46
46
|
const proxy = init?.proxy;
|
|
47
47
|
// Remove these fields before creating the request
|
|
48
48
|
if (init) {
|
|
@@ -50,6 +50,7 @@ async function fetch(input, init) {
|
|
|
50
50
|
delete init.connectTimeout;
|
|
51
51
|
delete init.proxy;
|
|
52
52
|
}
|
|
53
|
+
const signal = init?.signal;
|
|
53
54
|
const req = new Request(input, init);
|
|
54
55
|
const buffer = await req.arrayBuffer();
|
|
55
56
|
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
|
|
@@ -64,18 +65,22 @@ async function fetch(input, init) {
|
|
|
64
65
|
proxy,
|
|
65
66
|
},
|
|
66
67
|
});
|
|
67
|
-
|
|
68
|
+
signal?.addEventListener("abort", () => {
|
|
68
69
|
core.invoke("plugin:http|fetch_cancel", {
|
|
69
70
|
rid,
|
|
70
71
|
});
|
|
71
72
|
});
|
|
72
|
-
const { status, statusText, url, headers } = await core.invoke("plugin:http|fetch_send", {
|
|
73
|
+
const { status, statusText, url, headers, rid: responseRid, } = await core.invoke("plugin:http|fetch_send", {
|
|
73
74
|
rid,
|
|
74
75
|
});
|
|
75
76
|
const body = await core.invoke("plugin:http|fetch_read_body", {
|
|
76
|
-
rid,
|
|
77
|
+
rid: responseRid,
|
|
77
78
|
});
|
|
78
|
-
const res = new Response(
|
|
79
|
+
const res = new Response(body instanceof ArrayBuffer && body.byteLength
|
|
80
|
+
? body
|
|
81
|
+
: body instanceof Array && body.length
|
|
82
|
+
? new Uint8Array(body)
|
|
83
|
+
: null, {
|
|
79
84
|
headers,
|
|
80
85
|
status,
|
|
81
86
|
statusText,
|
package/dist-js/index.js
CHANGED
|
@@ -40,7 +40,7 @@ import { invoke } from '@tauri-apps/api/core';
|
|
|
40
40
|
*/
|
|
41
41
|
async function fetch(input, init) {
|
|
42
42
|
const maxRedirections = init?.maxRedirections;
|
|
43
|
-
const connectTimeout = init?.
|
|
43
|
+
const connectTimeout = init?.connectTimeout;
|
|
44
44
|
const proxy = init?.proxy;
|
|
45
45
|
// Remove these fields before creating the request
|
|
46
46
|
if (init) {
|
|
@@ -48,6 +48,7 @@ async function fetch(input, init) {
|
|
|
48
48
|
delete init.connectTimeout;
|
|
49
49
|
delete init.proxy;
|
|
50
50
|
}
|
|
51
|
+
const signal = init?.signal;
|
|
51
52
|
const req = new Request(input, init);
|
|
52
53
|
const buffer = await req.arrayBuffer();
|
|
53
54
|
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
|
|
@@ -62,18 +63,22 @@ async function fetch(input, init) {
|
|
|
62
63
|
proxy,
|
|
63
64
|
},
|
|
64
65
|
});
|
|
65
|
-
|
|
66
|
+
signal?.addEventListener("abort", () => {
|
|
66
67
|
invoke("plugin:http|fetch_cancel", {
|
|
67
68
|
rid,
|
|
68
69
|
});
|
|
69
70
|
});
|
|
70
|
-
const { status, statusText, url, headers } = await invoke("plugin:http|fetch_send", {
|
|
71
|
+
const { status, statusText, url, headers, rid: responseRid, } = await invoke("plugin:http|fetch_send", {
|
|
71
72
|
rid,
|
|
72
73
|
});
|
|
73
74
|
const body = await invoke("plugin:http|fetch_read_body", {
|
|
74
|
-
rid,
|
|
75
|
+
rid: responseRid,
|
|
75
76
|
});
|
|
76
|
-
const res = new Response(
|
|
77
|
+
const res = new Response(body instanceof ArrayBuffer && body.byteLength
|
|
78
|
+
? body
|
|
79
|
+
: body instanceof Array && body.length
|
|
80
|
+
? new Uint8Array(body)
|
|
81
|
+
: null, {
|
|
77
82
|
headers,
|
|
78
83
|
status,
|
|
79
84
|
statusText,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-http",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"license": "MIT or APACHE-2.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Tauri Programme within The Commons Conservancy"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"LICENSE"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tauri-apps/api": "2.0.0-
|
|
23
|
+
"@tauri-apps/api": "2.0.0-beta.2"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "rollup -c"
|