about summary refs log tree commit homepage
path: root/lib/clogger/pure.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-09-04 19:19:28 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-04 19:22:28 -0700
commit09cae70d5509530ed3abff9046b1dc0fe448b3b3 (patch)
treedeabdd22992cdb12876ab3be1624207ab4a62ace /lib/clogger/pure.rb
parent38e617b5a044ed91c799718d2188052c5646bc95 (diff)
downloadclogger-09cae70d5509530ed3abff9046b1dc0fe448b3b3.tar.gz
No point in having extra code to do case-insensitive lookups,
especially since the HeaderHash implementation is already in
wide use and will only get faster as time goes by.
Diffstat (limited to 'lib/clogger/pure.rb')
-rw-r--r--lib/clogger/pure.rb17
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/clogger/pure.rb b/lib/clogger/pure.rb
index 108d036..718db9a 100644
--- a/lib/clogger/pure.rb
+++ b/lib/clogger/pure.rb
@@ -1,6 +1,8 @@
 # -*- encoding: binary -*-
 # :stopdoc:
-#
+
+require 'rack'
+
 # Not at all optimized for performance, this was written based on
 # the original C extension code so it's not very Ruby-ish...
 class Clogger
@@ -23,6 +25,7 @@ class Clogger
       raise TypeError, "app response not a 3 element Array: #{resp.inspect}"
     end
     status, headers, body = resp
+    headers = Rack::Utils::HeaderHash.new(headers)
     if wrap_body?
       @reentrant = env['rack.multithread']
       @env, @status, @headers, @body = env, status, headers, body
@@ -114,7 +117,7 @@ private
       case op[0]
       when OP_LITERAL; op[1]
       when OP_REQUEST; byte_xs(env[op[1]] || "-")
-      when OP_RESPONSE; byte_xs(get_sent_header(headers, op[1]))
+      when OP_RESPONSE; byte_xs(headers[op[1]] || "-")
       when OP_SPECIAL; special_var(op[1], env, status, headers)
       when OP_EVAL; eval(op[1]).to_s rescue "-"
       when OP_TIME_LOCAL; Time.now.strftime(op[1])
@@ -133,14 +136,4 @@ private
     }.join('')
   end
 
-  def get_sent_header(headers, match)
-    headers.each do |pair|
-      Array === pair && pair.size >= 2 or
-        raise TypeError, "headers not returning pairs"
-      key, value = pair
-      match == key.downcase and return value
-    end
-    "-"
-  end
-
 end