@tauri-apps/plugin-http 2.0.0-alpha.5 → 2.0.0-beta.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/README.md +1 -1
- package/dist-js/index.cjs +16 -10
- package/dist-js/index.d.ts +41 -0
- package/dist-js/index.js +16 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -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,33 +42,39 @@ 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
|
+
const proxy = init?.proxy;
|
|
46
47
|
// Remove these fields before creating the request
|
|
47
48
|
if (init) {
|
|
48
49
|
delete init.maxRedirections;
|
|
49
50
|
delete init.connectTimeout;
|
|
51
|
+
delete init.proxy;
|
|
50
52
|
}
|
|
53
|
+
const signal = init?.signal;
|
|
51
54
|
const req = new Request(input, init);
|
|
52
55
|
const buffer = await req.arrayBuffer();
|
|
53
56
|
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
|
|
54
57
|
const rid = await core.invoke("plugin:http|fetch", {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
clientConfig: {
|
|
59
|
+
method: req.method,
|
|
60
|
+
url: req.url,
|
|
61
|
+
headers: Array.from(req.headers.entries()),
|
|
62
|
+
data: reqData,
|
|
63
|
+
maxRedirections,
|
|
64
|
+
connectTimeout,
|
|
65
|
+
proxy,
|
|
66
|
+
},
|
|
61
67
|
});
|
|
62
|
-
|
|
68
|
+
signal?.addEventListener("abort", () => {
|
|
63
69
|
core.invoke("plugin:http|fetch_cancel", {
|
|
64
70
|
rid,
|
|
65
71
|
});
|
|
66
72
|
});
|
|
67
|
-
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", {
|
|
68
74
|
rid,
|
|
69
75
|
});
|
|
70
76
|
const body = await core.invoke("plugin:http|fetch_read_body", {
|
|
71
|
-
rid,
|
|
77
|
+
rid: responseRid,
|
|
72
78
|
});
|
|
73
79
|
const res = new Response(new Uint8Array(body), {
|
|
74
80
|
headers,
|
package/dist-js/index.d.ts
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration of a proxy that a Client should pass requests to.
|
|
3
|
+
*
|
|
4
|
+
* @since 2.0.0
|
|
5
|
+
*/
|
|
6
|
+
export type Proxy = {
|
|
7
|
+
/**
|
|
8
|
+
* Proxy all traffic to the passed URL.
|
|
9
|
+
*/
|
|
10
|
+
all?: string | ProxyConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Proxy all HTTP traffic to the passed URL.
|
|
13
|
+
*/
|
|
14
|
+
http?: string | ProxyConfig;
|
|
15
|
+
/**
|
|
16
|
+
* Proxy all HTTPS traffic to the passed URL.
|
|
17
|
+
*/
|
|
18
|
+
https?: string | ProxyConfig;
|
|
19
|
+
};
|
|
20
|
+
export interface ProxyConfig {
|
|
21
|
+
/**
|
|
22
|
+
* The URL of the proxy server.
|
|
23
|
+
*/
|
|
24
|
+
url: string;
|
|
25
|
+
/**
|
|
26
|
+
* Set the `Proxy-Authorization` header using Basic auth.
|
|
27
|
+
*/
|
|
28
|
+
basicAuth?: {
|
|
29
|
+
username: string;
|
|
30
|
+
password: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* A configuration for filtering out requests that shouldn’t be proxied.
|
|
34
|
+
* Entries are expected to be comma-separated (whitespace between entries is ignored)
|
|
35
|
+
*/
|
|
36
|
+
noProxy?: string;
|
|
37
|
+
}
|
|
1
38
|
/**
|
|
2
39
|
* Options to configure the Rust client used to make fetch requests
|
|
3
40
|
*
|
|
@@ -11,6 +48,10 @@ export interface ClientOptions {
|
|
|
11
48
|
maxRedirections?: number;
|
|
12
49
|
/** Timeout in milliseconds */
|
|
13
50
|
connectTimeout?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Configuration of a proxy that a Client should pass requests to.
|
|
53
|
+
*/
|
|
54
|
+
proxy?: Proxy;
|
|
14
55
|
}
|
|
15
56
|
/**
|
|
16
57
|
* Fetch a resource from the network. It returns a `Promise` that resolves to the
|
package/dist-js/index.js
CHANGED
|
@@ -40,33 +40,39 @@ 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
|
+
const proxy = init?.proxy;
|
|
44
45
|
// Remove these fields before creating the request
|
|
45
46
|
if (init) {
|
|
46
47
|
delete init.maxRedirections;
|
|
47
48
|
delete init.connectTimeout;
|
|
49
|
+
delete init.proxy;
|
|
48
50
|
}
|
|
51
|
+
const signal = init?.signal;
|
|
49
52
|
const req = new Request(input, init);
|
|
50
53
|
const buffer = await req.arrayBuffer();
|
|
51
54
|
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
|
|
52
55
|
const rid = await invoke("plugin:http|fetch", {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
clientConfig: {
|
|
57
|
+
method: req.method,
|
|
58
|
+
url: req.url,
|
|
59
|
+
headers: Array.from(req.headers.entries()),
|
|
60
|
+
data: reqData,
|
|
61
|
+
maxRedirections,
|
|
62
|
+
connectTimeout,
|
|
63
|
+
proxy,
|
|
64
|
+
},
|
|
59
65
|
});
|
|
60
|
-
|
|
66
|
+
signal?.addEventListener("abort", () => {
|
|
61
67
|
invoke("plugin:http|fetch_cancel", {
|
|
62
68
|
rid,
|
|
63
69
|
});
|
|
64
70
|
});
|
|
65
|
-
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", {
|
|
66
72
|
rid,
|
|
67
73
|
});
|
|
68
74
|
const body = await invoke("plugin:http|fetch_read_body", {
|
|
69
|
-
rid,
|
|
75
|
+
rid: responseRid,
|
|
70
76
|
});
|
|
71
77
|
const res = new Response(new Uint8Array(body), {
|
|
72
78
|
headers,
|
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.0",
|
|
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.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "rollup -c"
|