File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
packages/s3-request-presigner/src Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -108,11 +108,12 @@ describe("s3 presigner", () => {
108108 expect ( signedHeaders ) . toContain ( "x-amz-server-side-encryption-customer-algorithm" ) ;
109109 } ) ;
110110
111- it ( "should inject host header if not supplied" , async ( ) => {
111+ it ( "should inject host header with port if not supplied" , async ( ) => {
112112 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 } ) ;
114115 expect ( signed . headers ) . toMatchObject ( {
115- host : minimalRequest . hostname ,
116+ host : ` ${ minimalRequest . hostname } : ${ port } ` ,
116117 } ) ;
117118 } ) ;
118119} ) ;
Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ export class S3RequestPresigner implements RequestPresigner {
4545 requestToSign . headers [ SHA256_HEADER ] = UNSIGNED_PAYLOAD ;
4646 if ( ! requestToSign . headers [ "host" ] ) {
4747 requestToSign . headers . host = requestToSign . hostname ;
48+ if ( requestToSign . port ) {
49+ requestToSign . headers . host = `${ requestToSign . headers . host } :${ requestToSign . port } ` ;
50+ }
4851 }
4952 return this . signer . presign ( requestToSign , {
5053 expiresIn : 900 ,
You can’t perform that action at this time.
0 commit comments