From bc1d1df38d7803ce9fdae05fc5129051eeed89e0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 6 Jun 2010 00:43:34 +0000 Subject: when wrapping the body, body.close writes the log We no longer write the log out at the end of the body.each call. This is a behavioral change, but fortunately all Rack servers I've seen call body.close inside an ensure. This allows us to later pass along the "to_path" method and not rely on "each" to write the log. --- lib/clogger/pure.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/clogger/pure.rb b/lib/clogger/pure.rb index e9a8e6a..50e4f6e 100644 --- a/lib/clogger/pure.rb +++ b/lib/clogger/pure.rb @@ -43,12 +43,13 @@ class Clogger @body_bytes_sent += Rack::Utils.bytesize(part) yield part end - ensure - log(@env, @status, @headers) + self end def close @body.close if @body.respond_to?(:close) + ensure + log(@env, @status, @headers) end def reentrant? -- cgit v1.2.3-24-ge0c7