]> Cypherpunks repositories - gostls13.git/commit
net/http/httptest: record failed ResponseWriter writes
authorDamien Neil <dneil@google.com>
Tue, 14 Oct 2025 18:25:29 +0000 (11:25 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 15 Oct 2025 21:41:11 +0000 (14:41 -0700)
commitb68cebd809f1335b4504837337f5702406720432
tree8ed13b52423295eec3d5313ae02067a9509dd60e
parentf1fed742ebbe781611c9f78398d9fa233ad0a8e6
net/http/httptest: record failed ResponseWriter writes

CL 709335 changed ResponseWriter.Write to return an error
when trying to write to a response with a status code which
doesn't permit a body, such as 304.

Continue to return an error, but still record the write in
ResponseWriter.Body. This maintains the documented property that
"the data in buf is written to rw.Body".

For #75471

Change-Id: I69139797559fe09d6580c5d25b4458f04263c60e
Reviewed-on: https://go-review.googlesource.com/c/go/+/711940
Reviewed-by: Sean Liao <sean@liao.dev>
TryBot-Bypass: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
src/net/http/httptest/recorder.go
src/net/http/httptest/recorder_test.go