-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: http.MaxBytesReader has a bug #14981
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
Comments
updated, see above |
Can you briefly describe the bug? It's not immediately obvious from the description. Is it confusion about whether the boundary value We don't take patches in the bug tracker. To submit a fix, see https://golang.org/doc/contribute.html. Although I suspect we'd just want to update documentation if this is a boundary issue. |
@bradfitz JUST for a io.Reader, I think the result is not correct
|
I suggest update documentation If changes the document to "returns a non-EOF error for a Read up to or beyond the limit", func (l *maxBytesReader) Read(p []byte) (n int, err error) {
if l.n <= 0 {
return l.tooLarge()
}
if int64(len(p)) > l.n {
p = p[:l.n]
}
n, err = l.r.Read(p)
l.n -= int64(n)
return
} |
If I understand this bug correctly, it's that @chanxuehong expects error values returned by Read to be the same on subsequent Read calls after a non-nil error was returned by Read. Generally Go doesn't make that promise on its io.Reader types, but we could here. |
CL https://golang.org/cl/23009 mentions this issue. |
Please answer these questions before submitting your issue. Thanks!
go version
)?go version go1.6 windows/amd64
go env
)?set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=d:\gopath
set GORACE=
set GOROOT=d:\go
set GOTOOLDIR=d:\go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=1
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
http://play.golang.org/p/bfo9_XiI49
here is my code to fix it.
The text was updated successfully, but these errors were encountered: