@tauri-apps/plugin-http 2.4.1 → 2.4.3
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 +10 -12
- package/dist-js/index.js +10 -12
- package/package.json +1 -1
package/dist-js/index.cjs
CHANGED
|
@@ -124,16 +124,15 @@ async function fetch(input, init) {
|
|
|
124
124
|
controller.error(ERROR_REQUEST_CANCELLED);
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
const resUint8 = new Uint8Array(res);
|
|
128
|
+
const lastByte = resUint8[resUint8.byteLength - 1];
|
|
129
|
+
const actualRes = resUint8.slice(0, resUint8.byteLength - 1);
|
|
130
|
+
// close when the signal to close (last byte is 1) is sent from the IPC.
|
|
131
|
+
if (lastByte == 1) {
|
|
130
132
|
controller.close();
|
|
131
133
|
return;
|
|
132
134
|
}
|
|
133
|
-
|
|
134
|
-
// must have Uint8Array as its content, else it will
|
|
135
|
-
// have untraceable error that's hard to debug.
|
|
136
|
-
controller.enqueue(new Uint8Array(res));
|
|
135
|
+
controller.enqueue(actualRes);
|
|
137
136
|
};
|
|
138
137
|
// run a non-blocking body stream fetch
|
|
139
138
|
core.invoke('plugin:http|fetch_read_body', {
|
|
@@ -148,12 +147,11 @@ async function fetch(input, init) {
|
|
|
148
147
|
status,
|
|
149
148
|
statusText
|
|
150
149
|
});
|
|
151
|
-
//
|
|
152
|
-
//
|
|
150
|
+
// Set `Response` properties that are ignored by the
|
|
151
|
+
// constructor, like url and some headers
|
|
153
152
|
//
|
|
154
|
-
//
|
|
155
|
-
//
|
|
156
|
-
// like `set-cookie` headers
|
|
153
|
+
// Since url and headers are read only properties
|
|
154
|
+
// this is the only way to set them.
|
|
157
155
|
Object.defineProperty(res, 'url', { value: url });
|
|
158
156
|
Object.defineProperty(res, 'headers', {
|
|
159
157
|
value: new Headers(responseHeaders)
|
package/dist-js/index.js
CHANGED
|
@@ -122,16 +122,15 @@ async function fetch(input, init) {
|
|
|
122
122
|
controller.error(ERROR_REQUEST_CANCELLED);
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
const resUint8 = new Uint8Array(res);
|
|
126
|
+
const lastByte = resUint8[resUint8.byteLength - 1];
|
|
127
|
+
const actualRes = resUint8.slice(0, resUint8.byteLength - 1);
|
|
128
|
+
// close when the signal to close (last byte is 1) is sent from the IPC.
|
|
129
|
+
if (lastByte == 1) {
|
|
128
130
|
controller.close();
|
|
129
131
|
return;
|
|
130
132
|
}
|
|
131
|
-
|
|
132
|
-
// must have Uint8Array as its content, else it will
|
|
133
|
-
// have untraceable error that's hard to debug.
|
|
134
|
-
controller.enqueue(new Uint8Array(res));
|
|
133
|
+
controller.enqueue(actualRes);
|
|
135
134
|
};
|
|
136
135
|
// run a non-blocking body stream fetch
|
|
137
136
|
invoke('plugin:http|fetch_read_body', {
|
|
@@ -146,12 +145,11 @@ async function fetch(input, init) {
|
|
|
146
145
|
status,
|
|
147
146
|
statusText
|
|
148
147
|
});
|
|
149
|
-
//
|
|
150
|
-
//
|
|
148
|
+
// Set `Response` properties that are ignored by the
|
|
149
|
+
// constructor, like url and some headers
|
|
151
150
|
//
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
// like `set-cookie` headers
|
|
151
|
+
// Since url and headers are read only properties
|
|
152
|
+
// this is the only way to set them.
|
|
155
153
|
Object.defineProperty(res, 'url', { value: url });
|
|
156
154
|
Object.defineProperty(res, 'headers', {
|
|
157
155
|
value: new Headers(responseHeaders)
|