@tauri-apps/plugin-http 2.0.0-beta.1 → 2.0.0-beta.2

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 CHANGED
@@ -51,6 +51,19 @@ async function fetch(input, init) {
51
51
  delete init.proxy;
52
52
  }
53
53
  const signal = init?.signal;
54
+ const headers = !init?.headers
55
+ ? []
56
+ : init.headers instanceof Headers
57
+ ? Array.from(init.headers.entries())
58
+ : Array.isArray(init.headers)
59
+ ? init.headers
60
+ : Object.entries(init.headers);
61
+ const mappedHeaders = headers.map(([name, val]) => [
62
+ name,
63
+ // we need to ensure we have all values as strings
64
+ // eslint-disable-next-line
65
+ typeof val === "string" ? val : val.toString(),
66
+ ]);
54
67
  const req = new Request(input, init);
55
68
  const buffer = await req.arrayBuffer();
56
69
  const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
@@ -58,7 +71,7 @@ async function fetch(input, init) {
58
71
  clientConfig: {
59
72
  method: req.method,
60
73
  url: req.url,
61
- headers: Array.from(req.headers.entries()),
74
+ headers: mappedHeaders,
62
75
  data: reqData,
63
76
  maxRedirections,
64
77
  connectTimeout,
@@ -70,7 +83,7 @@ async function fetch(input, init) {
70
83
  rid,
71
84
  });
72
85
  });
73
- const { status, statusText, url, headers, rid: responseRid, } = await core.invoke("plugin:http|fetch_send", {
86
+ const { status, statusText, url, headers: responseHeaders, rid: responseRid, } = await core.invoke("plugin:http|fetch_send", {
74
87
  rid,
75
88
  });
76
89
  const body = await core.invoke("plugin:http|fetch_read_body", {
@@ -81,7 +94,7 @@ async function fetch(input, init) {
81
94
  : body instanceof Array && body.length
82
95
  ? new Uint8Array(body)
83
96
  : null, {
84
- headers,
97
+ headers: responseHeaders,
85
98
  status,
86
99
  statusText,
87
100
  });
package/dist-js/index.js CHANGED
@@ -49,6 +49,19 @@ async function fetch(input, init) {
49
49
  delete init.proxy;
50
50
  }
51
51
  const signal = init?.signal;
52
+ const headers = !init?.headers
53
+ ? []
54
+ : init.headers instanceof Headers
55
+ ? Array.from(init.headers.entries())
56
+ : Array.isArray(init.headers)
57
+ ? init.headers
58
+ : Object.entries(init.headers);
59
+ const mappedHeaders = headers.map(([name, val]) => [
60
+ name,
61
+ // we need to ensure we have all values as strings
62
+ // eslint-disable-next-line
63
+ typeof val === "string" ? val : val.toString(),
64
+ ]);
52
65
  const req = new Request(input, init);
53
66
  const buffer = await req.arrayBuffer();
54
67
  const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
@@ -56,7 +69,7 @@ async function fetch(input, init) {
56
69
  clientConfig: {
57
70
  method: req.method,
58
71
  url: req.url,
59
- headers: Array.from(req.headers.entries()),
72
+ headers: mappedHeaders,
60
73
  data: reqData,
61
74
  maxRedirections,
62
75
  connectTimeout,
@@ -68,7 +81,7 @@ async function fetch(input, init) {
68
81
  rid,
69
82
  });
70
83
  });
71
- const { status, statusText, url, headers, rid: responseRid, } = await invoke("plugin:http|fetch_send", {
84
+ const { status, statusText, url, headers: responseHeaders, rid: responseRid, } = await invoke("plugin:http|fetch_send", {
72
85
  rid,
73
86
  });
74
87
  const body = await invoke("plugin:http|fetch_read_body", {
@@ -79,7 +92,7 @@ async function fetch(input, init) {
79
92
  : body instanceof Array && body.length
80
93
  ? new Uint8Array(body)
81
94
  : null, {
82
- headers,
95
+ headers: responseHeaders,
83
96
  status,
84
97
  statusText,
85
98
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-http",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
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-beta.2"
23
+ "@tauri-apps/api": "2.0.0-beta.4"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "rollup -c"