-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
What version of Go are you using (go version
)?
$ go version go version go1.12.6 darwin/amd64
Does this issue reproduce with the latest release?
Yes, it does.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GOARCH="amd64" GOBIN="" GOCACHE="/Users/a8327/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/a8327/go" GOPROXY="" GORACE="" GOROOT="/usr/local/Cellar/go/1.12.6/libexec" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.12.6/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/09/xght07y913s83cqxlwc_x3z017ny38/T/go-build169699103=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
https://play.golang.org/p/JO2CILHKDEQ
The issue is that method ParseFrom
of *net.http.Request
returns an error when the body of the request is not nil.
What did you expect to see?
I expect to see that the error is equal to nil.
As far as I understand, the issue stems from the fact that the body of a server POST request is always non-nil. However, it is possible to create a valid client POST request with nil body. The documentation of the method https://godoc.org/net/http#Request.ParseForm does not distinguish between a server and a client POST request. Therefore, it seems reasonable to assume that invoking the method on any valid request will not produce an error.
Therefore, it looks as it would make sense to adjust the documentation. The more general approach would be to change line https://golang.org/src/net/http/request.go#L1131 and do not return an error if the body is nil.
This issue was mentioned here: https://go-review.googlesource.com/c/go/+/48890/ which is now frozen. The last reply was:
Brad Fitzpatrick (On leave)
Abandoned
This seems stalled, so closing for now. Reopen (or ping us to reopen) if you want to continue work on this.
I can prepare a draft.
What did you see instead?
I see a non-nil error: missing form body
.