@smithy/fetch-http-handler 2.5.0 → 3.0.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.
- package/README.md +7 -0
- package/dist-cjs/index.js +11 -6
- package/dist-es/stream-collector.js +11 -6
- package/package.json +8 -25
package/README.md
CHANGED
|
@@ -2,3 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@smithy/fetch-http-handler)
|
|
4
4
|
[](https://www.npmjs.com/package/@smithy/fetch-http-handler)
|
|
5
|
+
|
|
6
|
+
This is the default `requestHandler` used for browser applications.
|
|
7
|
+
Since Node.js introduced experimental Web Streams API in v16.5.0 and made it stable in v21.0.0,
|
|
8
|
+
you can consider using `fetch-http-handler` in Node.js, although it's not recommended.
|
|
9
|
+
|
|
10
|
+
For the Node.js default `requestHandler` implementation, see instead
|
|
11
|
+
[`@smithy/node-http-handler`](https://www.npmjs.com/package/@smithy/node-http-handler).
|
package/dist-cjs/index.js
CHANGED
|
@@ -176,20 +176,25 @@ async function collectBlob(blob) {
|
|
|
176
176
|
}
|
|
177
177
|
__name(collectBlob, "collectBlob");
|
|
178
178
|
async function collectStream(stream) {
|
|
179
|
-
|
|
179
|
+
const chunks = [];
|
|
180
180
|
const reader = stream.getReader();
|
|
181
181
|
let isDone = false;
|
|
182
|
+
let length = 0;
|
|
182
183
|
while (!isDone) {
|
|
183
184
|
const { done, value } = await reader.read();
|
|
184
185
|
if (value) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
res.set(prior);
|
|
188
|
-
res.set(value, prior.length);
|
|
186
|
+
chunks.push(value);
|
|
187
|
+
length += value.length;
|
|
189
188
|
}
|
|
190
189
|
isDone = done;
|
|
191
190
|
}
|
|
192
|
-
|
|
191
|
+
const collected = new Uint8Array(length);
|
|
192
|
+
let offset = 0;
|
|
193
|
+
for (const chunk of chunks) {
|
|
194
|
+
collected.set(chunk, offset);
|
|
195
|
+
offset += chunk.length;
|
|
196
|
+
}
|
|
197
|
+
return collected;
|
|
193
198
|
}
|
|
194
199
|
__name(collectStream, "collectStream");
|
|
195
200
|
function readToBase64(blob) {
|
|
@@ -11,20 +11,25 @@ async function collectBlob(blob) {
|
|
|
11
11
|
return new Uint8Array(arrayBuffer);
|
|
12
12
|
}
|
|
13
13
|
async function collectStream(stream) {
|
|
14
|
-
|
|
14
|
+
const chunks = [];
|
|
15
15
|
const reader = stream.getReader();
|
|
16
16
|
let isDone = false;
|
|
17
|
+
let length = 0;
|
|
17
18
|
while (!isDone) {
|
|
18
19
|
const { done, value } = await reader.read();
|
|
19
20
|
if (value) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
res.set(prior);
|
|
23
|
-
res.set(value, prior.length);
|
|
21
|
+
chunks.push(value);
|
|
22
|
+
length += value.length;
|
|
24
23
|
}
|
|
25
24
|
isDone = done;
|
|
26
25
|
}
|
|
27
|
-
|
|
26
|
+
const collected = new Uint8Array(length);
|
|
27
|
+
let offset = 0;
|
|
28
|
+
for (const chunk of chunks) {
|
|
29
|
+
collected.set(chunk, offset);
|
|
30
|
+
offset += chunk.length;
|
|
31
|
+
}
|
|
32
|
+
return collected;
|
|
28
33
|
}
|
|
29
34
|
function readToBase64(blob) {
|
|
30
35
|
return new Promise((resolve, reject) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/fetch-http-handler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.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,7 @@
|
|
|
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 && karma start karma.conf.js"
|
|
16
|
+
"test": "yarn g:jest --coverage --forceExit && yarn g:karma start karma.conf.js"
|
|
17
17
|
},
|
|
18
18
|
"author": {
|
|
19
19
|
"name": "AWS SDK for JavaScript Team",
|
|
@@ -24,35 +24,18 @@
|
|
|
24
24
|
"module": "./dist-es/index.js",
|
|
25
25
|
"types": "./dist-types/index.d.ts",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@smithy/protocol-http": "^
|
|
28
|
-
"@smithy/querystring-builder": "^
|
|
29
|
-
"@smithy/types": "^
|
|
30
|
-
"@smithy/util-base64": "^
|
|
27
|
+
"@smithy/protocol-http": "^4.0.0",
|
|
28
|
+
"@smithy/querystring-builder": "^3.0.0",
|
|
29
|
+
"@smithy/types": "^3.0.0",
|
|
30
|
+
"@smithy/util-base64": "^3.0.0",
|
|
31
31
|
"tslib": "^2.6.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@smithy/abort-controller": "^
|
|
35
|
-
"@tsconfig/recommended": "1.0.1",
|
|
36
|
-
"@types/chai-as-promised": "^7.1.2",
|
|
37
|
-
"chai": "^4.2.0",
|
|
38
|
-
"chai-as-promised": "^7.1.1",
|
|
34
|
+
"@smithy/abort-controller": "^3.0.0",
|
|
39
35
|
"concurrently": "7.0.0",
|
|
40
36
|
"downlevel-dts": "0.10.1",
|
|
41
|
-
"karma": "6.4.0",
|
|
42
|
-
"karma-chai": "0.1.0",
|
|
43
|
-
"karma-chrome-launcher": "3.1.1",
|
|
44
|
-
"karma-coverage": "2.2.1",
|
|
45
|
-
"karma-env-preprocessor": "0.1.1",
|
|
46
|
-
"karma-firefox-launcher": "2.1.3",
|
|
47
|
-
"karma-jasmine": "5.1.0",
|
|
48
|
-
"karma-mocha": "2.0.1",
|
|
49
|
-
"karma-sourcemap-loader": "0.3.8",
|
|
50
|
-
"karma-typescript": "5.5.3",
|
|
51
|
-
"karma-webpack": "5.0.0",
|
|
52
37
|
"rimraf": "3.0.2",
|
|
53
|
-
"typedoc": "0.23.23"
|
|
54
|
-
"webpack": "5.76.0",
|
|
55
|
-
"webpack-cli": "4.10.0"
|
|
38
|
+
"typedoc": "0.23.23"
|
|
56
39
|
},
|
|
57
40
|
"typesVersions": {
|
|
58
41
|
"<4.0": {
|