From c03045ecde0f3270d7458ba7ac0d76a25afc6fb2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 29 Aug 2009 13:35:22 -0700 Subject: support "$request_uri" as a log variable This was documented in the README but never implemented. Some popular web servers set REQUEST_URI even though it's not required by Rack, so allow this variable to be used if possible. As a side effect, it is also less likely to be modified by certain handlers (*cough*Rails::Rack::Static*cough*). --- test/test_clogger.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/test_clogger.rb b/test/test_clogger.rb index f79017b..c3ae93c 100644 --- a/test/test_clogger.rb +++ b/test/test_clogger.rb @@ -333,6 +333,22 @@ class TestClogger < Test::Unit::TestCase assert_equal expect, str.string end + def test_request_uri_fallback + str = StringIO.new + app = lambda { |env| [ 200, {}, [] ] } + cl = Clogger.new(app, :logger => str, :format => '$request_uri') + status, headers, body = cl.call(@req) + assert_equal "/hello?goodbye=true\n", str.string + end + + def test_request_uri_set + str = StringIO.new + app = lambda { |env| [ 200, {}, [] ] } + cl = Clogger.new(app, :logger => str, :format => '$request_uri') + status, headers, body = cl.call(@req.merge("REQUEST_URI" => '/zzz')) + assert_equal "/zzz\n", str.string + end + def test_cookies str = StringIO.new app = lambda { |env| -- cgit v1.2.3-24-ge0c7