@smithy/fetch-http-handler 3.1.0 → 3.2.1
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-cjs/index.js
CHANGED
|
@@ -80,6 +80,7 @@ var _FetchHttpHandler = class _FetchHttpHandler {
|
|
|
80
80
|
}
|
|
81
81
|
const requestTimeoutInMs = this.config.requestTimeout;
|
|
82
82
|
const keepAlive = this.config.keepAlive === true;
|
|
83
|
+
const credentials = this.config.credentials;
|
|
83
84
|
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
84
85
|
const abortError = new Error("Request aborted");
|
|
85
86
|
abortError.name = "AbortError";
|
|
@@ -105,7 +106,8 @@ var _FetchHttpHandler = class _FetchHttpHandler {
|
|
|
105
106
|
const requestOptions = {
|
|
106
107
|
body,
|
|
107
108
|
headers: new Headers(request.headers),
|
|
108
|
-
method
|
|
109
|
+
method,
|
|
110
|
+
credentials
|
|
109
111
|
};
|
|
110
112
|
if (body) {
|
|
111
113
|
requestOptions.duplex = "half";
|
|
@@ -116,6 +118,7 @@ var _FetchHttpHandler = class _FetchHttpHandler {
|
|
|
116
118
|
if (keepAliveSupport.supported) {
|
|
117
119
|
requestOptions.keepalive = keepAlive;
|
|
118
120
|
}
|
|
121
|
+
let removeSignalEventListener = null;
|
|
119
122
|
const fetchRequest = new Request(url, requestOptions);
|
|
120
123
|
const raceOfPromises = [
|
|
121
124
|
fetch(fetchRequest).then((response) => {
|
|
@@ -155,14 +158,16 @@ var _FetchHttpHandler = class _FetchHttpHandler {
|
|
|
155
158
|
reject(abortError);
|
|
156
159
|
}, "onAbort");
|
|
157
160
|
if (typeof abortSignal.addEventListener === "function") {
|
|
158
|
-
abortSignal
|
|
161
|
+
const signal = abortSignal;
|
|
162
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
163
|
+
removeSignalEventListener = /* @__PURE__ */ __name(() => signal.removeEventListener("abort", onAbort), "removeSignalEventListener");
|
|
159
164
|
} else {
|
|
160
165
|
abortSignal.onabort = onAbort;
|
|
161
166
|
}
|
|
162
167
|
})
|
|
163
168
|
);
|
|
164
169
|
}
|
|
165
|
-
return Promise.race(raceOfPromises);
|
|
170
|
+
return Promise.race(raceOfPromises).finally(removeSignalEventListener);
|
|
166
171
|
}
|
|
167
172
|
updateHttpClientConfig(key, value) {
|
|
168
173
|
this.config = void 0;
|
|
@@ -31,6 +31,7 @@ export class FetchHttpHandler {
|
|
|
31
31
|
}
|
|
32
32
|
const requestTimeoutInMs = this.config.requestTimeout;
|
|
33
33
|
const keepAlive = this.config.keepAlive === true;
|
|
34
|
+
const credentials = this.config.credentials;
|
|
34
35
|
if (abortSignal?.aborted) {
|
|
35
36
|
const abortError = new Error("Request aborted");
|
|
36
37
|
abortError.name = "AbortError";
|
|
@@ -57,6 +58,7 @@ export class FetchHttpHandler {
|
|
|
57
58
|
body,
|
|
58
59
|
headers: new Headers(request.headers),
|
|
59
60
|
method: method,
|
|
61
|
+
credentials,
|
|
60
62
|
};
|
|
61
63
|
if (body) {
|
|
62
64
|
requestOptions.duplex = "half";
|
|
@@ -67,6 +69,7 @@ export class FetchHttpHandler {
|
|
|
67
69
|
if (keepAliveSupport.supported) {
|
|
68
70
|
requestOptions.keepalive = keepAlive;
|
|
69
71
|
}
|
|
72
|
+
let removeSignalEventListener = null;
|
|
70
73
|
const fetchRequest = new Request(url, requestOptions);
|
|
71
74
|
const raceOfPromises = [
|
|
72
75
|
fetch(fetchRequest).then((response) => {
|
|
@@ -105,14 +108,16 @@ export class FetchHttpHandler {
|
|
|
105
108
|
reject(abortError);
|
|
106
109
|
};
|
|
107
110
|
if (typeof abortSignal.addEventListener === "function") {
|
|
108
|
-
abortSignal
|
|
111
|
+
const signal = abortSignal;
|
|
112
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
113
|
+
removeSignalEventListener = () => signal.removeEventListener("abort", onAbort);
|
|
109
114
|
}
|
|
110
115
|
else {
|
|
111
116
|
abortSignal.onabort = onAbort;
|
|
112
117
|
}
|
|
113
118
|
}));
|
|
114
119
|
}
|
|
115
|
-
return Promise.race(raceOfPromises);
|
|
120
|
+
return Promise.race(raceOfPromises).finally(removeSignalEventListener);
|
|
116
121
|
}
|
|
117
122
|
updateHttpClientConfig(key, value) {
|
|
118
123
|
this.config = undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/fetch-http-handler",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
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'",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"module": "./dist-es/index.js",
|
|
25
25
|
"types": "./dist-types/index.d.ts",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@smithy/protocol-http": "^4.0.
|
|
28
|
-
"@smithy/querystring-builder": "^3.0.
|
|
29
|
-
"@smithy/types": "^3.
|
|
27
|
+
"@smithy/protocol-http": "^4.0.3",
|
|
28
|
+
"@smithy/querystring-builder": "^3.0.3",
|
|
29
|
+
"@smithy/types": "^3.3.0",
|
|
30
30
|
"@smithy/util-base64": "^3.0.0",
|
|
31
31
|
"tslib": "^2.6.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@smithy/abort-controller": "^3.1.
|
|
34
|
+
"@smithy/abort-controller": "^3.1.1",
|
|
35
35
|
"concurrently": "7.0.0",
|
|
36
36
|
"downlevel-dts": "0.10.1",
|
|
37
37
|
"rimraf": "3.0.2",
|