From 561e72427f3a8761b9ddf1f61b00a73c52b47a6f Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 7 Dec 2024 01:40:35 -0500 Subject: [PATCH] Fix HTTPResponseRecorder playing back a zero status code --- http.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/http.go b/http.go index bcb7bc6..d426ed9 100644 --- a/http.go +++ b/http.go @@ -45,11 +45,15 @@ func (this *HTTPResponseRecorder) WriteHeader (statusCode int) { // recorder. func (this *HTTPResponseRecorder) Play (res http.ResponseWriter) error { defer this.Reset() + status := this.Status + if status == 0 { + status = http.StatusOK + } header := res.Header() for name, value := range this.Head { header[name] = value } - res.WriteHeader(this.Status) + res.WriteHeader(status) _, err := io.Copy(res, &this.buffer) return err }