@smithy/middleware-content-length 2.0.17 → 2.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.
Files changed (2) hide show
  1. package/dist-cjs/index.js +64 -39
  2. package/package.json +5 -5
package/dist-cjs/index.js CHANGED
@@ -1,44 +1,69 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContentLengthPlugin = exports.contentLengthMiddlewareOptions = exports.contentLengthMiddleware = void 0;
4
- const protocol_http_1 = require("@smithy/protocol-http");
5
- const CONTENT_LENGTH_HEADER = "content-length";
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);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ contentLengthMiddleware: () => contentLengthMiddleware,
24
+ contentLengthMiddlewareOptions: () => contentLengthMiddlewareOptions,
25
+ getContentLengthPlugin: () => getContentLengthPlugin
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+ var import_protocol_http = require("@smithy/protocol-http");
29
+ var CONTENT_LENGTH_HEADER = "content-length";
6
30
  function contentLengthMiddleware(bodyLengthChecker) {
7
- return (next) => async (args) => {
8
- const request = args.request;
9
- if (protocol_http_1.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
- }
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) {
25
43
  }
26
- return next({
27
- ...args,
28
- request,
29
- });
30
- };
44
+ }
45
+ }
46
+ return next({
47
+ ...args,
48
+ request
49
+ });
50
+ };
31
51
  }
32
- exports.contentLengthMiddleware = contentLengthMiddleware;
33
- exports.contentLengthMiddlewareOptions = {
34
- step: "build",
35
- tags: ["SET_CONTENT_LENGTH", "CONTENT_LENGTH"],
36
- name: "contentLengthMiddleware",
37
- override: true,
52
+ __name(contentLengthMiddleware, "contentLengthMiddleware");
53
+ var contentLengthMiddlewareOptions = {
54
+ step: "build",
55
+ tags: ["SET_CONTENT_LENGTH", "CONTENT_LENGTH"],
56
+ name: "contentLengthMiddleware",
57
+ override: true
38
58
  };
39
- const getContentLengthPlugin = (options) => ({
40
- applyToStack: (clientStack) => {
41
- clientStack.add(contentLengthMiddleware(options.bodyLengthChecker), exports.contentLengthMiddlewareOptions);
42
- },
59
+ var getContentLengthPlugin = /* @__PURE__ */ __name((options) => ({
60
+ applyToStack: (clientStack) => {
61
+ clientStack.add(contentLengthMiddleware(options.bodyLengthChecker), contentLengthMiddlewareOptions);
62
+ }
63
+ }), "getContentLengthPlugin");
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ contentLengthMiddleware,
67
+ contentLengthMiddlewareOptions,
68
+ getContentLengthPlugin
43
69
  });
44
- exports.getContentLengthPlugin = getContentLengthPlugin;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@smithy/middleware-content-length",
3
- "version": "2.0.17",
3
+ "version": "2.1.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
6
- "build:cjs": "yarn g:tsc -p tsconfig.cjs.json",
6
+ "build:cjs": "node ../../scripts/inline middleware-content-length",
7
7
  "build:es": "yarn g:tsc -p tsconfig.es.json",
8
8
  "build:types": "yarn g:tsc -p tsconfig.types.json",
9
9
  "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@smithy/protocol-http": "^3.0.11",
27
- "@smithy/types": "^2.7.0",
26
+ "@smithy/protocol-http": "^3.1.0",
27
+ "@smithy/types": "^2.9.0",
28
28
  "tslib": "^2.5.0"
29
29
  },
30
30
  "engines": {
@@ -47,7 +47,7 @@
47
47
  "directory": "packages/middleware-content-length"
48
48
  },
49
49
  "devDependencies": {
50
- "@smithy/util-test": "^0.1.11",
50
+ "@smithy/util-test": "^0.1.13",
51
51
  "@tsconfig/recommended": "1.0.1",
52
52
  "concurrently": "7.0.0",
53
53
  "downlevel-dts": "0.10.1",