Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.12 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GOARCH="amd64" GOBIN="/Users/foo/go/bin" GOCACHE="/Users/foo/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/foo/go" GOPROXY="" GORACE="" GOROOT="/usr/local/Cellar/go/1.12/libexec" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.12/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/lf/rbfblwvx6rx3xhm68yksmqjwdv1dsf/T/go-build261266046=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Upon limiting the maximum request size (by using MaxBytesReader
as in https://stackoverflow.com/a/28292505/381140) I wanted to specially handle too large request body error in a clean way with error type assertion, and return custom response body.
More people asked for the same feature: https://groups.google.com/forum/#!topic/golang-nuts/gMzVGDgPyrY
What did you expect to see?
I expected net/http to have RequestBodyTooLargeError
defined and returned by MaxBytesReader
so type assertion can be done instead of error message comparison.
What did you see instead?
Trivial error string implementation is returned https://golang.org/src/net/http/request.go#L1114