Skip to content

Commit d86c436

Browse files
committed
Use the right header ordering for s3
1 parent ff55449 commit d86c436

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/security.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -929,16 +929,17 @@ export class FailsAssets {
929929
const path = 'https://' + host + uri
930930
const date = new Date()
931931
const length = input?.length || size
932-
const headers = {
932+
let headers = {
933933
'Content-Length': String(length),
934934
'Content-Type': mime,
935935
Date: date.toUTCString(),
936936
Host: host,
937937
'x-amz-content-sha256': shahex
938938
}
939939
const contentDisposition = this.mimeToContentDisposition(mime)
940-
if (contentDisposition)
941-
headers['Content-Disposition'] = contentDisposition
940+
if (contentDisposition) {
941+
headers = { 'Content-Disposition': contentDisposition, ...headers }
942+
}
942943
let response
943944
try {
944945
headers.Authorization = this.s3AuthHeader({
@@ -1047,16 +1048,17 @@ export class FailsAssets {
10471048
const date = new Date()
10481049
const length = size
10491050
const unsignedHash = 'UNSIGNED-PAYLOAD'
1050-
const headers = {
1051+
let headers = {
10511052
'Content-Length': String(length),
10521053
'Content-Type': mime,
10531054
Date: date.toUTCString(),
10541055
Host: host,
10551056
'x-amz-content-sha256': unsignedHash
10561057
}
10571058
const contentDisposition = this.mimeToContentDisposition(mime)
1058-
if (contentDisposition)
1059-
headers['Content-Disposition'] = contentDisposition
1059+
if (contentDisposition) {
1060+
headers = { 'Content-Disposition': contentDisposition, ...headers }
1061+
}
10601062

10611063
headers.Authorization = this.s3AuthHeader({
10621064
headers,

0 commit comments

Comments
 (0)