From 4cae518fd0b2ba81114ed4cc26eb1704a1f71e28 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 29 Aug 2009 13:39:58 -0700 Subject: Log bad/invalid app responses as 500 errors Some misbehaved apps can do this to us, and we don't want the C extension to segfault when this happens. --- test/test_clogger.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/test_clogger.rb') diff --git a/test/test_clogger.rb b/test/test_clogger.rb index c3ae93c..d2121da 100644 --- a/test/test_clogger.rb +++ b/test/test_clogger.rb @@ -362,4 +362,15 @@ class TestClogger < Test::Unit::TestCase status, headers, body = cl.call(req) assert_equal "bar h&m\n", str.string end + + def test_bogus_app_response + str = StringIO.new + app = lambda { |env| 302 } + cl = Clogger.new(app, :logger => str) + assert_raise(TypeError) { cl.call(@req) } + str = str.string + e = Regexp.quote " \"GET /hello?goodbye=true HTTP/1.0\" 500 -" + assert_match %r{#{e}$}m, str + end + end -- cgit v1.2.3-24-ge0c7