Description
What version of Go are you using (go version
)?
$ go version go version go1.17 darwin/arm64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go envGO111MODULE="on"
GOARCH="arm64"
GOBIN="/Users/tick/go/bin"
GOCACHE="/Users/tick/Library/Caches/go-build"
GOENV="/Users/tick/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/tick/go/pkg/mod"
GOOS="darwin"
GOPATH="/Users/tick/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.17/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.17/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gy/5ff3jzqj6gj5jc38zq91vd2h0000gn/T/go-build1908200583=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
This is my code, please generate your own certificate
package main import ( "fmt" "net/http" ) func main() { han := func(rw http.ResponseWriter, r *http.Request) { _, fh, err := r.FormFile("test") if err != nil { rw.Write([]byte(fmt.Sprintf("read from file failed, Err: %v", err))) return } rw.Write([]byte(fmt.Sprintf("total %d's byte", fh.Size))) } s := &http.Server{ Addr: ":8080", Handler: http.HandlerFunc(han), } s.ListenAndServeTLS("./server.crt", "./server.key") }
You can upload a large form using the following command.
curl -k -F 'test=@/path/to/large/file' https://localhost:8080
Note: The file must be large enough to exceed 32M for the following reasons: request form to large will create tmp to save.
go/src/mime/multipart/formdata.go
Line 92 in ec51703
What did you expect to see?
At the end of the HTTP request, files in /tmp will be destroyed.
What did you see instead?
Tmp file still exists.