File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed
middleware-content-length/src Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,7 @@ export function contentLengthMiddleware(
14
14
) : BuildHandler < any , Output , any > => async (
15
15
args : BuildHandlerArguments < any , any >
16
16
) : Promise < Output > => {
17
- const { request} = args ;
18
- if ( ! request ) {
19
- throw new Error ( 'Unable to determine request content-length due to missing request.' ) ;
20
- }
21
-
17
+ let request = { ...args . request } ;
22
18
const { body, headers} = request ;
23
19
if (
24
20
body &&
@@ -28,7 +24,10 @@ export function contentLengthMiddleware(
28
24
) {
29
25
const length = bodyLengthCalculator ( body ) ;
30
26
if ( length !== undefined ) {
31
- headers [ 'Content-Length' ] = String ( length ) ;
27
+ request . headers = {
28
+ ...request . headers ,
29
+ 'Content-Length' : String ( length ) ,
30
+ }
32
31
}
33
32
}
34
33
Original file line number Diff line number Diff line change @@ -5,10 +5,9 @@ import {
5
5
Middleware ,
6
6
MiddlewareStack as IMiddlewareStack ,
7
7
HandlerExecutionContext ,
8
+ Step ,
8
9
} from '@aws/types' ;
9
10
10
- export type Step = 'initialize' | 'build' | 'finalize' ;
11
-
12
11
interface HandlerListEntry <
13
12
Input extends object ,
14
13
Output extends object ,
@@ -20,11 +19,17 @@ interface HandlerListEntry<
20
19
tags ?: { [ tag : string ] : any } ;
21
20
}
22
21
22
+ export interface MiddlewareStack <
23
+ Input extends object ,
24
+ Output extends object ,
25
+ Stream = Uint8Array
26
+ > extends IMiddlewareStack < Input , Output , Stream > { }
27
+
23
28
export class MiddlewareStack <
24
29
Input extends object ,
25
30
Output extends object ,
26
31
Stream = Uint8Array
27
- > implements IMiddlewareStack < Input , Output , Stream > {
32
+ > {
28
33
private readonly entries : Array < HandlerListEntry < Input , Output , Stream > > = [ ] ;
29
34
private sorted : boolean = true ;
30
35
@@ -117,7 +122,8 @@ export class MiddlewareStack<
117
122
}
118
123
119
124
const stepWeights = {
120
- initialize : 3 ,
125
+ initialize : 4 ,
126
+ serialize : 3 ,
121
127
build : 2 ,
122
128
finalize : 1 ,
123
129
} ;
You can’t perform that action at this time.
0 commit comments