Hello,

I want to use http.MaxByteReader, but I want to know if it possible to 
return an package level error (like context.DeadlineExceeded) instead of 
create a new one 
(https://github.com/golang/go/blob/06f7e655d1764f5ad57bc14f82326c181c37901c/src/net/http/request.go#L1158).
 
It seems more goish and it is easiest to test with simple switch case 
instead of check the content of error (as example below).

Do you think that is compliance with promise of compatibility with Go 1? (I 
think that it is the case)


func TestMaxBytesReader(t *testing.T) {
req := ioutil.NopCloser(bytes.NewBufferString("my too long request"))
_, err := http.MaxBytesReader(httptest.NewRecorder(), req, 
2).Read([]byte{10: 0})
if err == nil || err.Error() != "http: request body too large" {
t.FailNow()
}
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/83b1df54-9c2c-4991-bbe1-5fd10ed11e99n%40googlegroups.com.

Reply via email to