Check if any header found in case of EOF to recognize header-only
messages and if so, return a Message with the found headers
and a body from the reader which is already empty.
Fixes #33823.
Change-Id: I2f0396b08e9be4e6c89c212ce62b9c87b5f63123
GitHub-Last-Rev:
356a9420837bf7e247247f7dc7c8a1d218684aeb
GitHub-Pull-Request: golang/go#47898
Reviewed-on: https://go-review.googlesource.com/c/go/+/344269
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
tp := textproto.NewReader(bufio.NewReader(r))
hdr, err := tp.ReadMIMEHeader()
- if err != nil {
+ if err != nil && (err != io.EOF || len(hdr) == 0) {
return nil, err
}
},
body: "This is a message just to say hello.\nSo, \"Hello\".\n",
},
+ {
+ // RFC 5965, Appendix B.1, a part of the multipart message (a header-only sub message)
+ in: `Feedback-Type: abuse
+User-Agent: SomeGenerator/1.0
+Version: 1
+`,
+ header: Header{
+ "Feedback-Type": []string{"abuse"},
+ "User-Agent": []string{"SomeGenerator/1.0"},
+ "Version": []string{"1"},
+ },
+ body: "",
+ },
}
func TestParsing(t *testing.T) {