lib/clogger/pure.rb in clogger-0.0.3 vs lib/clogger/pure.rb in clogger-0.0.4

- old
+ new

@@ -60,11 +60,11 @@ private def byte_xs(s) s = s.dup s.force_encoding(Encoding::BINARY) if defined?(Encoding::BINARY) - s.gsub!(/(['"\x00-\x1f])/) { |x| "\\x#{$1.unpack('H2').first}" } + s.gsub!(/(['"\x00-\x1f])/) { |x| "\\x#{$1.unpack('H2').first.upcase}" } s end SPECIAL_RMAP = SPECIAL_VARS.inject([]) { |ary, (k,v)| ary[v] = k; ary } @@ -81,15 +81,15 @@ @body_bytes_sent.to_s when :status status = status.to_i status >= 100 && status <= 999 ? ('%03d' % status) : '-' when :request + version = env['HTTP_VERSION'] and version = " #{byte_xs(version)}" qs = env['QUERY_STRING'] qs.empty? or qs = "?#{byte_xs(qs)}" "#{env['REQUEST_METHOD']} " \ - "#{request_uri(env)} " \ - "#{byte_xs(env['HTTP_VERSION'])}" + "#{request_uri(env)}#{version}" when :request_uri request_uri(env) when :request_length env['rack.input'].size.to_s when :response_length @@ -131,10 +131,15 @@ end }.join('') end def get_sent_header(headers, match) - headers.each { |key, value| match == key.downcase and return value } + 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