I’ve got an http endpoint which calls net/http.(*Request).FormFile
to read a file uploaded. I noticed the returned *multipart.File
is never closed with Close()
. That is fine for small files as it is a no-op, but It appears that https://golang.org/src/net/http/request.go#L1369 r.ParseMultipartForm
will copy the file out of memory and into a temp file if the file is larger than 32MB. You can see the os.Open
call here: https://golang.org/src/mime/multipart/formdata.go?s=3614:3656#L146
AFAICT this would leak file handles, but when I examine the process, I do not see leaking file handles. Where is this cleaned up?
UPDATE: Here is a complete program for testing: https://play.golang.org/p/79_kt46t1PQ