@aws-sdk/middleware-content-length
Advanced tools
Comparing version 0.1.0-preview.7 to 1.0.0-alpha.1
@@ -1,2 +0,6 @@ | ||
import { BuildMiddleware, BodyLengthCalculator } from "@aws-sdk/types"; | ||
export declare function contentLengthMiddleware(bodyLengthCalculator: BodyLengthCalculator): BuildMiddleware<any, any, any>; | ||
import { BuildMiddleware, BodyLengthCalculator, Pluggable, BuildHandlerOptions } from "@aws-sdk/types"; | ||
export declare function contentLengthMiddleware(bodyLengthChecker: BodyLengthCalculator): BuildMiddleware<any, any>; | ||
export declare const contentLengthMiddlewareOptions: BuildHandlerOptions; | ||
export declare const getContentLengthPlugin: (options: { | ||
bodyLengthChecker: BodyLengthCalculator; | ||
}) => Pluggable<any, any>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
function contentLengthMiddleware(bodyLengthCalculator) { | ||
var protocol_http_1 = require("@aws-sdk/protocol-http"); | ||
var CONTENT_LENGTH_HEADER = "content-length"; | ||
function contentLengthMiddleware(bodyLengthChecker) { | ||
var _this = this; | ||
return function (next) { return function (args) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var request, body, headers, length; | ||
return tslib_1.__generator(this, function (_a) { | ||
request = tslib_1.__assign({}, args.request); | ||
body = request.body, headers = request.headers; | ||
if (body && | ||
Object.keys(headers) | ||
.map(function (str) { return str.toLowerCase(); }) | ||
.indexOf("content-length") === -1) { | ||
length = bodyLengthCalculator(body); | ||
if (length !== undefined) { | ||
request.headers = tslib_1.__assign({}, request.headers, { "Content-Length": String(length) }); | ||
var _a, request, body, headers, length; | ||
return tslib_1.__generator(this, function (_b) { | ||
request = args.request; | ||
if (protocol_http_1.HttpRequest.isInstance(request)) { | ||
body = request.body, headers = request.headers; | ||
if (body && | ||
Object.keys(headers) | ||
.map(function (str) { return str.toLowerCase(); }) | ||
.indexOf(CONTENT_LENGTH_HEADER) === -1) { | ||
length = bodyLengthChecker(body); | ||
if (length !== undefined) { | ||
request.headers = tslib_1.__assign({}, request.headers, (_a = {}, _a[CONTENT_LENGTH_HEADER] = String(length), _a)); | ||
} | ||
} | ||
@@ -25,2 +29,12 @@ } | ||
exports.contentLengthMiddleware = contentLengthMiddleware; | ||
//# sourceMappingURL=index.js.map | ||
exports.contentLengthMiddlewareOptions = { | ||
step: "build", | ||
tags: ["SET_CONTENT_LENGTH", "CONTENT_LENGTH"], | ||
name: "contentLengthMiddleware" | ||
}; | ||
exports.getContentLengthPlugin = function (options) { return ({ | ||
applyToStack: function (clientStack) { | ||
clientStack.add(contentLengthMiddleware(options.bodyLengthChecker), exports.contentLengthMiddlewareOptions); | ||
} | ||
}); }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBVUEsd0RBQXFEO0FBRXJELElBQU0scUJBQXFCLEdBQUcsZ0JBQWdCLENBQUM7QUFFL0MsU0FBZ0IsdUJBQXVCLENBQ3JDLGlCQUF1QztJQUR6QyxpQkFnQ0M7SUE3QkMsT0FBTyxVQUNMLElBQStCLElBQ0QsT0FBQSxVQUM5QixJQUFnQzs7O1lBRTVCLE9BQU8sR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDO1lBQzNCLElBQUksMkJBQVcsQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLEVBQUU7Z0JBQzNCLElBQUksR0FBYyxPQUFPLEtBQXJCLEVBQUUsT0FBTyxHQUFLLE9BQU8sUUFBWixDQUFhO2dCQUNsQyxJQUNFLElBQUk7b0JBQ0osTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7eUJBQ2pCLEdBQUcsQ0FBQyxVQUFBLEdBQUcsSUFBSSxPQUFBLEdBQUcsQ0FBQyxXQUFXLEVBQUUsRUFBakIsQ0FBaUIsQ0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-alpha.1](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/middleware-content-length@0.1.0-preview.2...@aws-sdk/middleware-content-length@1.0.0-alpha.1) (2020-01-08) | ||
### Bug Fixes | ||
* update updated types ([#474](https://github.com/aws/aws-sdk-js-v3/issues/474)) ([9efac3e](https://github.com/aws/aws-sdk-js-v3/commit/9efac3e)) | ||
* **middleware-content-length:** header name ([5fb3936](https://github.com/aws/aws-sdk-js-v3/commit/5fb3936)) | ||
### Features | ||
* remove absolute priority numbers from middleware stack ([#434](https://github.com/aws/aws-sdk-js-v3/issues/434)) ([2ad5796](https://github.com/aws/aws-sdk-js-v3/commit/2ad5796)) | ||
* standardize plugins ([#422](https://github.com/aws/aws-sdk-js-v3/issues/422)) ([09112e5](https://github.com/aws/aws-sdk-js-v3/commit/09112e5)) | ||
* update runtime plugin interface ([#400](https://github.com/aws/aws-sdk-js-v3/issues/400)) ([d75c620](https://github.com/aws/aws-sdk-js-v3/commit/d75c620)) | ||
* use flag to replace httprequest instanceof ([b584032](https://github.com/aws/aws-sdk-js-v3/commit/b584032)) | ||
# 0.6.0 (2019-10-30) | ||
# 0.3.0 (2019-09-09) | ||
### Features | ||
* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed)) | ||
# 0.2.0 (2019-07-12) | ||
### Features | ||
* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c)) | ||
* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab)) | ||
# 0.1.0 (2019-04-19) | ||
# [0.1.0-preview.7](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/middleware-content-length@0.1.0-preview.2...@aws-sdk/middleware-content-length@0.1.0-preview.7) (2019-10-30) | ||
@@ -8,0 +55,0 @@ |
{ | ||
"name": "@aws-sdk/middleware-content-length", | ||
"version": "0.1.0-preview.7", | ||
"version": "1.0.0-alpha.1", | ||
"scripts": { | ||
@@ -17,3 +17,4 @@ "prepublishOnly": "tsc", | ||
"dependencies": { | ||
"@aws-sdk/types": "^0.1.0-preview.7", | ||
"@aws-sdk/protocol-http": "^1.0.0-alpha.1", | ||
"@aws-sdk/types": "^1.0.0-alpha.1", | ||
"tslib": "^1.8.0" | ||
@@ -20,0 +21,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24071
70
3
8
+ Added@aws-sdk/protocol-http@1.0.0-rc.10(transitive)
+ Added@aws-sdk/types@1.0.0-rc.10(transitive)
- Removed@aws-sdk/types@0.1.0-preview.7(transitive)