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: r.MultipartReader() reports not multipart when boundary is empty string #32342

Open
MrCreosote opened this issue May 30, 2019 · 0 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@MrCreosote
Copy link

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

1.12

Does this issue reproduce with the latest release?

N/A

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

Ubuntu 18.04

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/[home]/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/[home]/go"
GOPROXY=""
GORACE=""
GOROOT="/home/[home]/.go"
GOTMPDIR=""
GOTOOLDIR="/home/[home]/.go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build210454728=/tmp/go-build -gno-record-gcc-switches"

What did you do?

func TestMimeBoundary(t *testing.T) {
	for _, b := range []string{"", " boundary="} {
		r := http.Request{}
		r.Header = make(http.Header)
		r.Header.Set("Content-Type", "multipart/form-data;" + b)
		_, err := r.MultipartReader()
		fmt.Printf("%T %v\n", err, err)
	}
}

Results in:

*http.ProtocolError no multipart boundary param in Content-Type
*http.ProtocolError request Content-Type isn't multipart/form-data

This means comparing errors against http.ErrNotMultipart is not reliable.

What did you expect to see?

I would expect an error that doesn't assert that data with the content type multipart/form-data is not multipart/form-data. More abstractly, I would expect a set of errors to compare against such that when the error is http.ErrNotMultipart it is reliable to proceed assuming the client did not intend the http body to be multipart rather than they just bolloxed it up.

What did you see instead?

As above.

@julieqiu julieqiu changed the title r.MultipartReader() reports not multipart when boundary is empty string net/http: r.MultipartReader() reports not multipart when boundary is empty string Jun 1, 2019
@julieqiu julieqiu added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 1, 2019
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 6, 2019
@dmitshur dmitshur added this to the Go1.14 milestone Jun 6, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants