@smithy/fetch-http-handler 4.0.0 → 4.1.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.
@@ -0,0 +1 @@
1
+ module.exports = require("./index.js");
package/dist-cjs/index.js CHANGED
@@ -30,6 +30,12 @@ module.exports = __toCommonJS(src_exports);
30
30
  var import_protocol_http = require("@smithy/protocol-http");
31
31
  var import_querystring_builder = require("@smithy/querystring-builder");
32
32
 
33
+ // src/create-request.ts
34
+ function createRequest(url, requestOptions) {
35
+ return new Request(url, requestOptions);
36
+ }
37
+ __name(createRequest, "createRequest");
38
+
33
39
  // src/request-timeout.ts
34
40
  function requestTimeout(timeoutInMs = 0) {
35
41
  return new Promise((resolve, reject) => {
@@ -68,7 +74,7 @@ var _FetchHttpHandler = class _FetchHttpHandler {
68
74
  }
69
75
  if (keepAliveSupport.supported === void 0) {
70
76
  keepAliveSupport.supported = Boolean(
71
- typeof Request !== "undefined" && "keepalive" in new Request("https://[::1]")
77
+ typeof Request !== "undefined" && "keepalive" in createRequest("https://[::1]")
72
78
  );
73
79
  }
74
80
  }
@@ -127,7 +133,7 @@ var _FetchHttpHandler = class _FetchHttpHandler {
127
133
  }
128
134
  let removeSignalEventListener = /* @__PURE__ */ __name(() => {
129
135
  }, "removeSignalEventListener");
130
- const fetchRequest = new Request(url, requestOptions);
136
+ const fetchRequest = createRequest(url, requestOptions);
131
137
  const raceOfPromises = [
132
138
  fetch(fetchRequest).then((response) => {
133
139
  const fetchHeaders = response.headers;
@@ -193,7 +199,8 @@ var FetchHttpHandler = _FetchHttpHandler;
193
199
 
194
200
  // src/stream-collector.ts
195
201
  var streamCollector = /* @__PURE__ */ __name(async (stream) => {
196
- if (typeof Blob === "function" && stream instanceof Blob) {
202
+ var _a;
203
+ if (typeof Blob === "function" && stream instanceof Blob || ((_a = stream.constructor) == null ? void 0 : _a.name) === "Blob") {
197
204
  return new Uint8Array(await stream.arrayBuffer());
198
205
  }
199
206
  return collectStream(stream);
@@ -0,0 +1,3 @@
1
+ export function createRequest(url, requestOptions) {
2
+ return new Request(url, requestOptions);
3
+ }
@@ -1,5 +1,6 @@
1
1
  import { HttpResponse } from "@smithy/protocol-http";
2
2
  import { buildQueryString } from "@smithy/querystring-builder";
3
+ import { createRequest } from "./create-request";
3
4
  import { requestTimeout } from "./request-timeout";
4
5
  export const keepAliveSupport = {
5
6
  supported: undefined,
@@ -20,7 +21,7 @@ export class FetchHttpHandler {
20
21
  this.configProvider = Promise.resolve(this.config);
21
22
  }
22
23
  if (keepAliveSupport.supported === undefined) {
23
- keepAliveSupport.supported = Boolean(typeof Request !== "undefined" && "keepalive" in new Request("https://[::1]"));
24
+ keepAliveSupport.supported = Boolean(typeof Request !== "undefined" && "keepalive" in createRequest("https://[::1]"));
24
25
  }
25
26
  }
26
27
  destroy() {
@@ -76,7 +77,7 @@ export class FetchHttpHandler {
76
77
  Object.assign(requestOptions, this.config.requestInit(request));
77
78
  }
78
79
  let removeSignalEventListener = () => { };
79
- const fetchRequest = new Request(url, requestOptions);
80
+ const fetchRequest = createRequest(url, requestOptions);
80
81
  const raceOfPromises = [
81
82
  fetch(fetchRequest).then((response) => {
82
83
  const fetchHeaders = response.headers;
@@ -1,5 +1,5 @@
1
1
  export const streamCollector = async (stream) => {
2
- if (typeof Blob === "function" && stream instanceof Blob) {
2
+ if ((typeof Blob === "function" && stream instanceof Blob) || stream.constructor?.name === "Blob") {
3
3
  return new Uint8Array(await stream.arrayBuffer());
4
4
  }
5
5
  return collectStream(stream);
@@ -0,0 +1,6 @@
1
+ import { AdditionalRequestParameters } from "./fetch-http-handler";
2
+ /**
3
+ * @internal
4
+ * For mocking/interception.
5
+ */
6
+ export declare function createRequest(url: string, requestOptions?: RequestInit & AdditionalRequestParameters): Request;
@@ -10,6 +10,12 @@ type FetchHttpHandlerConfig = FetchHttpHandlerOptions;
10
10
  export declare const keepAliveSupport: {
11
11
  supported: boolean | undefined;
12
12
  };
13
+ /**
14
+ * @internal
15
+ */
16
+ export type AdditionalRequestParameters = {
17
+ duplex?: "half";
18
+ };
13
19
  /**
14
20
  * @public
15
21
  *
@@ -0,0 +1,6 @@
1
+ import { AdditionalRequestParameters } from "./fetch-http-handler";
2
+ /**
3
+ * @internal
4
+ * For mocking/interception.
5
+ */
6
+ export declare function createRequest(url: string, requestOptions?: RequestInit & AdditionalRequestParameters): Request;
@@ -10,6 +10,12 @@ type FetchHttpHandlerConfig = FetchHttpHandlerOptions;
10
10
  export declare const keepAliveSupport: {
11
11
  supported: boolean | undefined;
12
12
  };
13
+ /**
14
+ * @internal
15
+ */
16
+ export type AdditionalRequestParameters = {
17
+ duplex?: "half";
18
+ };
13
19
  /**
14
20
  * @public
15
21
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/fetch-http-handler",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Provides a way to make requests",
5
5
  "scripts": {
6
6
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
@@ -13,7 +13,10 @@
13
13
  "lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
14
14
  "format": "prettier --config ../../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\"",
15
15
  "extract:docs": "api-extractor run --local",
16
- "test": "yarn g:jest --coverage --forceExit && yarn g:karma start karma.conf.js"
16
+ "test": "yarn g:vitest run && yarn test:browser",
17
+ "test:watch": "yarn g:vitest watch",
18
+ "test:browser": "yarn g:vitest run -c vitest.config.browser.ts",
19
+ "test:browser:watch": "yarn g:vitest watch -c vitest.config.browser.ts"
17
20
  },
18
21
  "author": {
19
22
  "name": "AWS SDK for JavaScript Team",
@@ -24,14 +27,14 @@
24
27
  "module": "./dist-es/index.js",
25
28
  "types": "./dist-types/index.d.ts",
26
29
  "dependencies": {
27
- "@smithy/protocol-http": "^4.1.5",
28
- "@smithy/querystring-builder": "^3.0.8",
29
- "@smithy/types": "^3.6.0",
30
+ "@smithy/protocol-http": "^4.1.6",
31
+ "@smithy/querystring-builder": "^3.0.9",
32
+ "@smithy/types": "^3.7.0",
30
33
  "@smithy/util-base64": "^3.0.0",
31
34
  "tslib": "^2.6.2"
32
35
  },
33
36
  "devDependencies": {
34
- "@smithy/abort-controller": "^3.1.6",
37
+ "@smithy/abort-controller": "^3.1.7",
35
38
  "concurrently": "7.0.0",
36
39
  "downlevel-dts": "0.10.1",
37
40
  "rimraf": "3.0.2",