add body length tag

This commit is contained in:
Stéphane Depierrepont aka Toorop
2015-05-06 15:41:32 +02:00
parent 6b2f38361d
commit d33d1a64e8
4 changed files with 23 additions and 2 deletions

View File

@@ -199,7 +199,6 @@ func NewDkimHeaderBySigOptions(options sigOptions) *DkimHeader {
h.SignatureTimestamp = time.Now()
}
if options.SignatureExpireIn > 0 {
fmt.Println(options.SignatureExpireIn)
h.SignatureExpiration = time.Now().Add(time.Duration(options.SignatureExpireIn) * time.Second)
}
h.CopiedHeaderFileds = options.CopiedHeaderFileds
@@ -253,6 +252,16 @@ func (d *DkimHeader) GetHeaderBase(bodyHash string) string {
subh += " x=" + fmt.Sprintf("%d", ts) + ";"
}
// body length
if d.BodyLength != 0 {
bodyLengthStr := fmt.Sprintf("%d", d.BodyLength)
if len(subh)+len(bodyLengthStr)+4 > MaxHeaderLineLength {
h += subh + FWS
subh = ""
}
subh += " l=" + bodyLengthStr + ";"
}
// Headers
if len(subh)+len(d.Headers)+4 > MaxHeaderLineLength {
h += subh + FWS
@@ -287,7 +296,6 @@ func (d *DkimHeader) GetHeaderBase(bodyHash string) string {
}
}
h += subh + ";" + FWS + "b="
return h
}