1
0
mirror of https://github.com/golang/go synced 2024-11-25 06:37:58 -07:00

httptest: default the Recorder status code to 200 on a Write

This matches the real ResponseWriter behavior.

R=rsc
CC=golang-dev
https://golang.org/cl/4291048
This commit is contained in:
Brad Fitzpatrick 2011-03-15 10:13:25 -07:00
parent 5245b27ed8
commit f192891786

View File

@ -42,6 +42,9 @@ func (rw *ResponseRecorder) Write(buf []byte) (int, os.Error) {
if rw.Body != nil { if rw.Body != nil {
rw.Body.Write(buf) rw.Body.Write(buf)
} }
if rw.Code == 0 {
rw.Code = http.StatusOK
}
return len(buf), nil return len(buf), nil
} }