fix(GODT-2212): Preserver Header order in message building

https://github.com/ProtonMail/go-proton-api/pull/100
This commit is contained in:
Leander Beernaert
2023-09-25 14:32:46 +02:00
parent a1a5ffba5d
commit e422b28bc3
7 changed files with 37 additions and 22 deletions

View File

@ -64,12 +64,20 @@ func newTestMessageWithHeaders(
func newRawTestMessageWithHeaders(messageID, addressID, mimeType, body string, date time.Time, headers map[string][]string) proton.Message {
msgHeaders := proton.Headers{
"Content-Type": {mimeType},
"Date": {date.In(time.UTC).Format(time.RFC1123Z)},
Values: map[string][]string{
"Content-Type": {mimeType},
"Date": {date.In(time.UTC).Format(time.RFC1123Z)},
},
Order: []string{"Content-Type", "Date"},
}
for k, v := range headers {
msgHeaders[k] = v
_, ok := msgHeaders.Values[k]
if !ok {
msgHeaders.Order = append(msgHeaders.Order, k)
}
msgHeaders.Values[k] = v
}
return proton.Message{
@ -98,9 +106,12 @@ func addTestAttachment(
Name: name,
MIMEType: rfc822.MIMEType(mimeType),
Headers: proton.Headers{
"Content-Type": {mimeType},
"Content-Disposition": {disposition},
"Content-Transfer-Encoding": {"base64"},
Values: map[string][]string{
"Content-Type": {mimeType},
"Content-Disposition": {disposition},
"Content-Transfer-Encoding": {"base64"},
},
Order: []string{"Content-Type", "Content-Disposition", "Content-Transfer-Encoding"},
},
Disposition: proton.Disposition(disposition),
KeyPackets: base64.StdEncoding.EncodeToString(enc.GetBinaryKeyPacket()),