@tauri-apps/plugin-http 2.5.7 → 2.5.9

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
@@ -165,14 +165,28 @@ async function fetch(input, init) {
165
165
  status,
166
166
  statusText
167
167
  });
168
- // Set `Response` properties that are ignored by the
169
- // constructor, like url and some headers
170
- //
171
- // Since url and headers are read only properties
172
- // this is the only way to set them.
173
- Object.defineProperty(res, 'url', { value: url });
168
+ // `Response.url` cannot be set via the constructor, so we define it manually
169
+ Object.defineProperty(res, 'url', { value: url, writable: false });
170
+ // Expose `set-cookie` via `response.headers` (and `getSetCookie()` where
171
+ // supported). This is not Fetch-spec compliant for network responses in
172
+ // browsers, where `set-cookie` is treated as a forbidden response
173
+ // header and is generally not readable from JavaScript.
174
174
  Object.defineProperty(res, 'headers', {
175
- value: new Headers(responseHeaders)
175
+ value: new Headers(responseHeaders),
176
+ writable: false
177
+ });
178
+ // Patch clone() per-instance so cloning preserves the overridden properties
179
+ const originalClone = res.clone.bind(res);
180
+ Object.defineProperty(res, 'clone', {
181
+ value: () => {
182
+ const cloned = originalClone();
183
+ Object.defineProperty(cloned, 'url', { value: url, writable: false });
184
+ Object.defineProperty(cloned, 'headers', {
185
+ value: new Headers(responseHeaders),
186
+ writable: false
187
+ });
188
+ return cloned;
189
+ }
176
190
  });
177
191
  return res;
178
192
  }
package/dist-js/index.js CHANGED
@@ -163,14 +163,28 @@ async function fetch(input, init) {
163
163
  status,
164
164
  statusText
165
165
  });
166
- // Set `Response` properties that are ignored by the
167
- // constructor, like url and some headers
168
- //
169
- // Since url and headers are read only properties
170
- // this is the only way to set them.
171
- Object.defineProperty(res, 'url', { value: url });
166
+ // `Response.url` cannot be set via the constructor, so we define it manually
167
+ Object.defineProperty(res, 'url', { value: url, writable: false });
168
+ // Expose `set-cookie` via `response.headers` (and `getSetCookie()` where
169
+ // supported). This is not Fetch-spec compliant for network responses in
170
+ // browsers, where `set-cookie` is treated as a forbidden response
171
+ // header and is generally not readable from JavaScript.
172
172
  Object.defineProperty(res, 'headers', {
173
- value: new Headers(responseHeaders)
173
+ value: new Headers(responseHeaders),
174
+ writable: false
175
+ });
176
+ // Patch clone() per-instance so cloning preserves the overridden properties
177
+ const originalClone = res.clone.bind(res);
178
+ Object.defineProperty(res, 'clone', {
179
+ value: () => {
180
+ const cloned = originalClone();
181
+ Object.defineProperty(cloned, 'url', { value: url, writable: false });
182
+ Object.defineProperty(cloned, 'headers', {
183
+ value: new Headers(responseHeaders),
184
+ writable: false
185
+ });
186
+ return cloned;
187
+ }
174
188
  });
175
189
  return res;
176
190
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-http",
3
- "version": "2.5.7",
3
+ "version": "2.5.9",
4
4
  "license": "MIT OR Apache-2.0",
5
5
  "authors": [
6
6
  "Tauri Programme within The Commons Conservancy"
@@ -24,6 +24,6 @@
24
24
  "LICENSE"
25
25
  ],
26
26
  "dependencies": {
27
- "@tauri-apps/api": "^2.10.1"
27
+ "@tauri-apps/api": "^2.11.0"
28
28
  }
29
29
  }