From 87b24d3b7ee421b636d1725de95aff6cfb55c22c Mon Sep 17 00:00:00 2001 From: Simon Green Date: Wed, 27 May 2015 21:11:57 -0600 Subject: [PATCH] Response reset size Set size to 0 when response reset Prevents logged size accumulating with each request --- response.go | 1 + response_test.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/response.go b/response.go index caa191bf..2a76607b 100644 --- a/response.go +++ b/response.go @@ -76,6 +76,7 @@ func (r *Response) Size() int64 { func (r *Response) reset(w http.ResponseWriter) { r.writer = w + r.size = 0 r.status = http.StatusOK r.committed = false } diff --git a/response_test.go b/response_test.go index e1e966f6..f7296c2a 100644 --- a/response_test.go +++ b/response_test.go @@ -37,4 +37,10 @@ func TestResponse(t *testing.T) { if r.Size() != int64(len(s)) { t.Errorf("size should be %d", len(s)) } + + // reser + r.reset(httptest.NewRecorder()) + if r.Size() != int64(0) { + t.Error("size should be 0") + } }