@@ -3,8 +3,9 @@ import { getEndpointFromInstructions, toEndpointV1 } from "@smithy/middleware-en
33import { HttpRequest } from "@smithy/protocol-http" ;
44import { SignatureV4 } from "@smithy/signature-v4" ;
55import { extendedEncodeURIComponent } from "@smithy/smithy-client" ;
6- import {
6+ import type {
77 AwsCredentialIdentity ,
8+ BodyLengthCalculator ,
89 ChecksumConstructor ,
910 Endpoint ,
1011 HandlerExecutionContext ,
@@ -29,6 +30,7 @@ interface PreviouslyResolved {
2930 sha256 : ChecksumConstructor | HashConstructor ;
3031 signingEscapePath : boolean ;
3132 regionInfoProvider ?: RegionInfoProvider ;
33+ bodyLengthChecker : BodyLengthCalculator ;
3234}
3335
3436const version = "2016-11-15" ;
@@ -113,8 +115,8 @@ export function copySnapshotPresignedUrlMiddleware(options: PreviouslyResolved):
113115 } ,
114116 } ;
115117
116- // we also double-check the work of the serialzier here
117- // because this middleware may be placed after the regular serialzier .
118+ // we also double-check the work of the serializer here
119+ // because this middleware may be placed after the regular serializer .
118120 if ( HttpRequest . isInstance ( args . request ) ) {
119121 const { request } = args ;
120122 if ( ! ( request . body ?? "" ) . includes ( "DestinationRegion=" ) ) {
@@ -123,6 +125,9 @@ export function copySnapshotPresignedUrlMiddleware(options: PreviouslyResolved):
123125 if ( ! ( request . body ?? "" ) . includes ( "PresignedUrl=" ) ) {
124126 request . body += `&PresignedUrl=${ extendedEncodeURIComponent ( args . input . PresignedUrl ) } ` ;
125127 }
128+ if ( typeof options . bodyLengthChecker === "function" ) {
129+ request . headers [ "content-length" ] = String ( options . bodyLengthChecker ( request . body ) ) ;
130+ }
126131 }
127132 }
128133
0 commit comments