From daedc0bc171c97f834c8d928f7cb49f1e1309a13 Mon Sep 17 00:00:00 2001 From: Matt Newberry Date: Tue, 2 Sep 2014 13:17:37 -0400 Subject: [PATCH] Add response body size to writer interface --- response_writer.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/response_writer.go b/response_writer.go index 3ce84142..7088fcf6 100644 --- a/response_writer.go +++ b/response_writer.go @@ -20,6 +20,7 @@ type ( http.CloseNotifier Status() int + Size() int Written() bool WriteHeaderNow() } @@ -27,6 +28,7 @@ type ( responseWriter struct { http.ResponseWriter status int + size int written bool } ) @@ -55,13 +57,19 @@ func (w *responseWriter) WriteHeaderNow() { func (w *responseWriter) Write(data []byte) (n int, err error) { w.WriteHeaderNow() - return w.ResponseWriter.Write(data) + n, err = w.ResponseWriter.Write(data) + w.size = n + return } func (w *responseWriter) Status() int { return w.status } +func (w *responseWriter) Size() int { + return w.size +} + func (w *responseWriter) Written() bool { return w.written }