@smithy/middleware-content-length 4.1.1 → 4.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 +39 -64
- package/package.json +3 -3
package/dist-cjs/index.js
CHANGED
|
@@ -1,71 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
contentLengthMiddleware: () => contentLengthMiddleware,
|
|
24
|
-
contentLengthMiddlewareOptions: () => contentLengthMiddlewareOptions,
|
|
25
|
-
getContentLengthPlugin: () => getContentLengthPlugin
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
var import_protocol_http = require("@smithy/protocol-http");
|
|
29
|
-
var CONTENT_LENGTH_HEADER = "content-length";
|
|
3
|
+
var protocolHttp = require('@smithy/protocol-http');
|
|
4
|
+
|
|
5
|
+
const CONTENT_LENGTH_HEADER = "content-length";
|
|
30
6
|
function contentLengthMiddleware(bodyLengthChecker) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
7
|
+
return (next) => async (args) => {
|
|
8
|
+
const request = args.request;
|
|
9
|
+
if (protocolHttp.HttpRequest.isInstance(request)) {
|
|
10
|
+
const { body, headers } = request;
|
|
11
|
+
if (body &&
|
|
12
|
+
Object.keys(headers)
|
|
13
|
+
.map((str) => str.toLowerCase())
|
|
14
|
+
.indexOf(CONTENT_LENGTH_HEADER) === -1) {
|
|
15
|
+
try {
|
|
16
|
+
const length = bodyLengthChecker(body);
|
|
17
|
+
request.headers = {
|
|
18
|
+
...request.headers,
|
|
19
|
+
[CONTENT_LENGTH_HEADER]: String(length),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
43
25
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
};
|
|
26
|
+
return next({
|
|
27
|
+
...args,
|
|
28
|
+
request,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
51
31
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
override: true
|
|
32
|
+
const contentLengthMiddlewareOptions = {
|
|
33
|
+
step: "build",
|
|
34
|
+
tags: ["SET_CONTENT_LENGTH", "CONTENT_LENGTH"],
|
|
35
|
+
name: "contentLengthMiddleware",
|
|
36
|
+
override: true,
|
|
58
37
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}), "getContentLengthPlugin");
|
|
64
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
-
|
|
66
|
-
0 && (module.exports = {
|
|
67
|
-
contentLengthMiddlewareOptions,
|
|
68
|
-
getContentLengthPlugin,
|
|
69
|
-
contentLengthMiddleware
|
|
38
|
+
const getContentLengthPlugin = (options) => ({
|
|
39
|
+
applyToStack: (clientStack) => {
|
|
40
|
+
clientStack.add(contentLengthMiddleware(options.bodyLengthChecker), contentLengthMiddlewareOptions);
|
|
41
|
+
},
|
|
70
42
|
});
|
|
71
43
|
|
|
44
|
+
exports.contentLengthMiddleware = contentLengthMiddleware;
|
|
45
|
+
exports.contentLengthMiddlewareOptions = contentLengthMiddlewareOptions;
|
|
46
|
+
exports.getContentLengthPlugin = getContentLengthPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/middleware-content-length",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
6
6
|
"build:cjs": "node ../../scripts/inline middleware-content-length",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@smithy/protocol-http": "^5.
|
|
29
|
-
"@smithy/types": "^4.
|
|
28
|
+
"@smithy/protocol-http": "^5.3.1",
|
|
29
|
+
"@smithy/types": "^4.7.0",
|
|
30
30
|
"tslib": "^2.6.2"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|