From 9d1afbf308f2ac382f364f935867ce0cef0a3573 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 11 May 2023 15:23:39 +0700 Subject: mime/multipart: fix ReadForm always return (nil,io.EOF) Previously, the condition err == io.EOF in readForm will never true and break; it always goes to the second condition, err != nil, which cause the returned ReadForm always nil with err is io.EOF. As the test, we use the example with body almost similar to ExampleNewReader with header contains "Content-Disposition:form-data". Change-Id: I7268f45bb26eafb7f1e6e471b86eec681dde99f7 --- src/mime/multipart/formdata.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mime/multipart/formdata.go') diff --git a/src/mime/multipart/formdata.go b/src/mime/multipart/formdata.go index f8258a961c..f2ca0118a6 100644 --- a/src/mime/multipart/formdata.go +++ b/src/mime/multipart/formdata.go @@ -108,7 +108,7 @@ func (r *Reader) readForm(maxMemory int64) (_ *Form, err error) { var copyBuf []byte for { p, err := r.nextPart(false, maxMemoryBytes, maxHeaders) - if err == io.EOF { + if errors.Is(err, io.EOF) { break } if err != nil { -- cgit v1.3