Fix HTTPResponseRecorder playing back a zero status code

This commit is contained in:
Sasha Koshka 2024-12-07 01:40:35 -05:00
parent e292c9fbb2
commit 561e72427f

View File

@ -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
}