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: MaxBytesReader's "request body too large" error is unexported #8479

Closed
gopherbot opened this issue Aug 6, 2014 · 2 comments
Closed

Comments

@gopherbot
Copy link

by staley.dylan:

I recently ran into an issue where my program was printing "http: request body too
large". I found where that error is created in the package source
(http://golang.org/src/pkg/net/http/request.go#L656), but it seems that the error isn't
exported out of the package, so my application can't properly detect this specific error.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-none.

@bradfitz
Copy link
Contributor

Comment 2:

These need to be evaluated on a case-bv-case basis, so changing the subject.
At least in this case if you really care about the difference between too large and
other errors, you can simply count the incoming bytes yourself.
The real magic of MaxBytesReader is that it lets you not only stop reading (like an
io.LimitReader), but also marks the underlying http connection as dead, so it's not
reused in the next request. This mattered in more before Go 1.2 when it would always try
to advance to the next request if your handler didn't reach EOF on its own.  Nowadays
MaxBytesReader is convenient but not really required for anything.  I don't think it's
worth exporting more things in net/http or expanding any documentation for this case.
Nothing in the current code precludes people with special needs from doing what they
need.
If there are other unexported errors, please file separate bugs for them.

Status changed to WontFix.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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

3 participants