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

mime/multipart: net/http Request.FormValue() / Request.FormFile() behave differently between go1.9.2 and go1.10 #24060

Closed
Ogditsira opened this issue Feb 23, 2018 · 3 comments

Comments

@Ogditsira
Copy link

Hey guys,
this might be more like a question than an issue, but is this behavior intended ?
I am getting the data from a multipart request in different ways using go1.9.2 and go1.10.

Might have something to do with: https://golang.org/doc/go1.10#mime/multipart

What version of Go are you using (go version)?

go1.9.2 linux/amd64
go1.10 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/master/GoDev" GORACE="" GOROOT="/usr/local/go" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build036320343=/tmp/go-build -gno-record-gcc-switches" CXX="g++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config"

What did you do?

  • Sending HTTP Post Request containing multipart/form-data to go HTTP-Server
  • Try to retrieve form-data

Code:
Playground

Post:

POST HTTP/1.1
Host: localhost:4000
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Cache-Control: no-cache
Postman-Token: de8ee739-757a-6107-bbe8-61134864d695

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="test"
Content-Type: text/plain

Hello go!
------WebKitFormBoundary7MA4YWxkTrZu0gW--

What did you expect to see?

Getting the content with reg.FormValue("test")
go1.9.2:
http: no such file
Form Value: Hello go!

What did you see instead?

Getting the content with req.FormFile("test")
go1.10:
Form File: Hello go!
Form Value:

@Ogditsira Ogditsira changed the title mime/multipart: net/http Request.FormValue() / Request.FormFile behave differently between go1.9.2 and go1.10 mime/multipart: net/http Request.FormValue() / Request.FormFile() behave differently between go1.9.2 and go1.10 Feb 23, 2018
@peczenyj
Copy link

Hello

I think it was related to #24041

@bradfitz
Copy link
Contributor

Let's dup this into #24041.

@nilsmagnus
Copy link
Contributor

Ok, will have a look at this tomorrow.

@golang golang locked and limited conversation to collaborators Feb 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants