Hello,
I am facing to unexpected behavior when I want to limit the maximum body 
request and managing the request/response as streaming way.

With this code https://play.golang.org/p/eN2XEpiPdhn, when I send the 
request, I have this unexpected error (whatever the max size):

```
2021/06/18 15:48:49 http: panic serving 127.0.0.1:39024: http: invalid Read 
on closed Body
goroutine 6 [running]:
net/http.(*conn).serve.func1(0xc000110960)
        net/http/server.go:1824 +0x153
panic(0x671b60, 0xc000012af0)
        runtime/panic.go:971 +0x499
main.serve(0x713cd0, 0xc0001480e0, 0xc000164000)
        autodebit/service/order/cmd/main.go:32 +0x3b7
net/http.HandlerFunc.ServeHTTP(0x6d2608, 0x713cd0, 0xc0001480e0, 
0xc000164000)
        net/http/server.go:2069 +0x44
net/http.serverHandler.ServeHTTP(0xc000148000, 0x713cd0, 0xc0001480e0, 
0xc000164000)
        net/http/server.go:2887 +0xa3
net/http.(*conn).serve(0xc000110960, 0x714180, 0xc000028280)
        net/http/server.go:1952 +0x8cd
created by net/http.(*Server).Serve
        net/http/server.go:3013 +0x39b
```

But if I discard the response (via io.Discard) that works as expected 
https://play.golang.org/p/ZOJQz6EC--V

I don't understand what it is going wrong. Can I use http.MaxBytesReader 
when I send response as streaming way?

Thanks for your help
Jérôme

the body file seems too big to be in attach, I put it on 
https://sharetext.me/iveuebzrfq
the curl cmd: 
curl POST 'http://127.0.0.1:8081' --data-binary '@body.jsonl'

-- 
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/87cc19b1-29ad-403d-a403-ce6970ac02bbn%40googlegroups.com.

Reply via email to