@smithy/middleware-content-length 4.1.1 → 4.2.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.
Files changed (2) hide show
  1. package/dist-cjs/index.js +39 -64
  2. package/package.json +3 -3
package/dist-cjs/index.js CHANGED
@@ -1,71 +1,46 @@
1
- var __defProp = Object.defineProperty;
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
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
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
- return (next) => async (args) => {
32
- const request = args.request;
33
- if (import_protocol_http.HttpRequest.isInstance(request)) {
34
- const { body, headers } = request;
35
- if (body && Object.keys(headers).map((str) => str.toLowerCase()).indexOf(CONTENT_LENGTH_HEADER) === -1) {
36
- try {
37
- const length = bodyLengthChecker(body);
38
- request.headers = {
39
- ...request.headers,
40
- [CONTENT_LENGTH_HEADER]: String(length)
41
- };
42
- } catch (error) {
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
- return next({
47
- ...args,
48
- request
49
- });
50
- };
26
+ return next({
27
+ ...args,
28
+ request,
29
+ });
30
+ };
51
31
  }
52
- __name(contentLengthMiddleware, "contentLengthMiddleware");
53
- var contentLengthMiddlewareOptions = {
54
- step: "build",
55
- tags: ["SET_CONTENT_LENGTH", "CONTENT_LENGTH"],
56
- name: "contentLengthMiddleware",
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
- var getContentLengthPlugin = /* @__PURE__ */ __name((options) => ({
60
- applyToStack: /* @__PURE__ */ __name((clientStack) => {
61
- clientStack.add(contentLengthMiddleware(options.bodyLengthChecker), contentLengthMiddlewareOptions);
62
- }, "applyToStack")
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.1.1",
3
+ "version": "4.2.0",
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.2.1",
29
- "@smithy/types": "^4.5.0",
28
+ "@smithy/protocol-http": "^5.3.0",
29
+ "@smithy/types": "^4.6.0",
30
30
  "tslib": "^2.6.2"
31
31
  },
32
32
  "engines": {