// ErrContentLength is returned by ResponseWriter.Write calls
// when a Handler set a Content-Length response header with a
// declared size and then attempted to write more bytes than
// declared.
ErrContentLength = errors.New("http: wrote more than the declared Content-Length")
Writing too many bytes to an HTTP/2 body doesn't return ErrContentLength
, however, for two reasons:
- The HTTP/2
ResponseWriter
returns a different error when detecting a too-long body. - The accounting for how many bytes have been written can fail to detect a too-long body until after the
ResponseWriter.Write
call has returned.
The existing testTestIdentityResponse
fails when run in HTTP/2 mode.
4条答案
按热度按时间2skhul331#
你好,@neild,我可以试一下吗?☺️
evrscar22#
嘿,@neild,我可以试一下吗?☺️
请试试!我很乐意审阅一个CL。
ulydmbyx3#
https://go.dev/cl/450255提到了这个问题:
net/http: ResponseWriter checks for the Content-Length before writing it
zed5wv104#
https://go.dev/cl/577415提到了这个问题:
net/http: update HandlerWritesTooMuch test to allow different h1/h2 behavior