diff --git a/http/client.go b/http/client.go index 138dab6..7063808 100644 --- a/http/client.go +++ b/http/client.go @@ -127,7 +127,7 @@ func (c *Client) wrap(req *http.Request) error { length := make([]byte, 4) binary.LittleEndian.PutUint32(length, uint32(len(signature))) - body, newContentType, err := Wrap(concat(length, signature, sealed), contentType) + body, newContentType, err := Wrap(concat(length, signature, sealed), contentType, len(body)) if err != nil { return err } diff --git a/http/mime.go b/http/mime.go index e044baa..d996cca 100644 --- a/http/mime.go +++ b/http/mime.go @@ -98,7 +98,7 @@ func fromWSMV(r io.Reader) io.Reader { }) } -func Wrap(input []byte, ct string) ([]byte, string, error) { +func Wrap(input []byte, ct string, contentLength int) ([]byte, string, error) { b := &bytes.Buffer{} writer := multipart.NewWriter(b) @@ -109,7 +109,7 @@ func Wrap(input []byte, ct string) ([]byte, string, error) { header := make(textproto.MIMEHeader) header.Set(contentTypeHeader, mimeProtocol) // Using Set() will canonicalise this to "Originalcontent" which may cause problems - header["OriginalContent"] = []string{fmt.Sprintf("type=%s;Length=%d", ct, len(input))} + header["OriginalContent"] = []string{fmt.Sprintf("type=%s;Length=%d", ct, contentLength)} if _, err := writer.CreatePart(header); err != nil { return nil, "", err