http request entity too large

1,143 views
Skip to first unread message

Keith Rarick

unread,
Jul 13, 2012, 9:02:53 PM7/13/12
to golang-nuts
I'm using http.MaxBytesReader and I'd like to return
either status 413 or status 500 to the client, depending
on whether the limit was reached or some other error
happened.

How about making errors.New("http: request body too large")
into a public variable of package http?

kr

Brad Fitzpatrick

unread,
Jul 13, 2012, 11:05:05 PM7/13/12
to Keith Rarick, golang-nuts
Connect the dots for me.

What does making it public accomplish?  Can't you just return that error message/code on your own?

Patrick Mylund Nielsen

unread,
Jul 13, 2012, 11:15:37 PM7/13/12
to Brad Fitzpatrick, Keith Rarick, golang-nuts
Just guessing -- it's to "catch" that error, not return it:

if err == http.RequestBodyTooLarge {
        http.Error(w, "File too large", http.StatusRequestEntityTooLarge)
} else {
        http.Error(w, "Oops, there was an error. Please try again later.", http.StatusInternalServerError)

Keith Rarick

unread,
Jul 14, 2012, 5:01:40 PM7/14/12
to Patrick Mylund Nielsen, Brad Fitzpatrick, golang-nuts
Yeah, that. Sorry I didn't say so in the first place.

kr

Nicolas Martyanoff

unread,
Feb 1, 2017, 6:07:52 AM2/1/17
to golang-nuts
Is there any update regarding this issue ? The inability to make the difference between an error triggered by the request size and any other error is a real problem.

Stevo Slavić

unread,
Mar 10, 2019, 6:37:08 AM3/10/19
to golang-nuts
I've just created improvement request https://github.com/golang/go/issues/30715
Reply all
Reply to author
Forward
0 new messages