File tree 2 files changed +7
-3
lines changed
packages/s3-request-presigner/src
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -108,11 +108,12 @@ describe("s3 presigner", () => {
108
108
expect ( signedHeaders ) . toContain ( "x-amz-server-side-encryption-customer-algorithm" ) ;
109
109
} ) ;
110
110
111
- it ( "should inject host header if not supplied" , async ( ) => {
111
+ it ( "should inject host header with port if not supplied" , async ( ) => {
112
112
const signer = new S3RequestPresigner ( s3ResolvedConfig ) ;
113
- const signed = await signer . presign ( minimalRequest ) ;
113
+ const port = 12345 ;
114
+ const signed = await signer . presign ( { ...minimalRequest , headers : { } , port } ) ;
114
115
expect ( signed . headers ) . toMatchObject ( {
115
- host : minimalRequest . hostname ,
116
+ host : ` ${ minimalRequest . hostname } : ${ port } ` ,
116
117
} ) ;
117
118
} ) ;
118
119
} ) ;
Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ export class S3RequestPresigner implements RequestPresigner {
45
45
requestToSign . headers [ SHA256_HEADER ] = UNSIGNED_PAYLOAD ;
46
46
if ( ! requestToSign . headers [ "host" ] ) {
47
47
requestToSign . headers . host = requestToSign . hostname ;
48
+ if ( requestToSign . port ) {
49
+ requestToSign . headers . host = `${ requestToSign . headers . host } :${ requestToSign . port } ` ;
50
+ }
48
51
}
49
52
return this . signer . presign ( requestToSign , {
50
53
expiresIn : 900 ,
You can’t perform that action at this time.
0 commit comments