From 3bc7000a34c8e1788a5951381c7007f617233da2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 2 Sep 2009 18:29:58 -0700 Subject: [PATCH] alias $http_content_{length,type} to $content_{length,type} Since Rack doesn't allow the HTTP_CONTENT_{LENGTH,TYPE} headers, alias attempts to use those to the non-"HTTP_"-prefixed equivalents to avoid confusion on the user side (nginx also does this). --- lib/clogger.rb | 2 ++ test/test_clogger.rb | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/clogger.rb b/lib/clogger.rb index 52f2723..fb25e1e 100644 --- a/lib/clogger.rb +++ b/lib/clogger.rb @@ -19,6 +19,8 @@ class Clogger '$time_local' => '$time_local{%d/%b/%Y:%H:%M:%S %z}', '$msec' => '$time{3}', '$usec' => '$time{6}', + '$http_content_length' => '$content_length', + '$http_content_type' => '$content_type', } SPECIAL_VARS = { diff --git a/test/test_clogger.rb b/test/test_clogger.rb index 4dc1371..8e6604e 100644 --- a/test/test_clogger.rb +++ b/test/test_clogger.rb @@ -426,4 +426,12 @@ class TestClogger < Test::Unit::TestCase assert_equal "5\n", str.string end + def test_http_content_type_fallback + str = StringIO.new + app = lambda { |env| [302, [ %w(a) ], []] } + cl = Clogger.new(app, :logger => str, :format => '$http_content_type') + cl.call(@req.merge('CONTENT_TYPE' => 'text/plain')) + assert_equal "text/plain\n", str.string + end + end -- 2.11.4.GIT