Commit 73d741fd authored by Yasuhiro Matsumoto's avatar Yasuhiro Matsumoto Committed by Brad Fitzpatrick

mime/multipart: remove newline at top of the multipart.

R=golang-dev, bradfitz, arctanofyourface
CC=golang-dev
https://golang.org/cl/4635063
parent d8474670
......@@ -61,7 +61,11 @@ func (w *Writer) CreatePart(header textproto.MIMEHeader) (io.Writer, os.Error) {
}
}
var b bytes.Buffer
fmt.Fprintf(&b, "\r\n--%s\r\n", w.boundary)
if w.lastpart != nil {
fmt.Fprintf(&b, "\r\n--%s\r\n", w.boundary)
} else {
fmt.Fprintf(&b, "--%s\r\n", w.boundary)
}
// TODO(bradfitz): move this to textproto.MimeHeader.Write(w), have it sort
// and clean, like http.Header.Write(w) does.
for k, vv := range header {
......
......@@ -30,6 +30,13 @@ func TestWriter(t *testing.T) {
if err != nil {
t.Fatalf("Close: %v", err)
}
s := b.String()
if len(s) == 0 {
t.Fatal("String: unexpected empty result")
}
if s[0] == '\r' || s[0] == '\n' {
t.Fatal("String: unexpected newline")
}
}
r := NewReader(&b, w.Boundary())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment