Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: method *request.ParseForm return an error #32665

Closed
ayzu opened this issue Jun 18, 2019 · 1 comment
Closed

net/http: method *request.ParseForm return an error #32665

ayzu opened this issue Jun 18, 2019 · 1 comment

Comments

@ayzu
Copy link

@ayzu ayzu commented Jun 18, 2019

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.

@katiehockman

This comment has been minimized.

Copy link
Member

@katiehockman katiehockman commented Jun 19, 2019

Since there is already an issue and a CL open for this, please continue the conversation in those places.

Duplicate of #20988

@katiehockman katiehockman changed the title net.http: method *request.ParseForm return an error net/http: method *request.ParseForm return an error Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.