]> Cypherpunks repositories - gostls13.git/commitdiff
httptest: default the Recorder status code to 200 on a Write
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 15 Mar 2011 17:13:25 +0000 (10:13 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 15 Mar 2011 17:13:25 +0000 (10:13 -0700)
This matches the real ResponseWriter behavior.

R=rsc
CC=golang-dev
https://golang.org/cl/4291048

src/pkg/http/httptest/recorder.go

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