From 79d0d7d6387a2553002efa63421dfb8e35a96da3 Mon Sep 17 00:00:00 2001 From: Aleksandar Kostadinov Date: Tue, 31 Jan 2017 17:29:53 +0200 Subject: [PATCH] allow viewing request headers --- config.ru | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config.ru b/config.ru index a709f06..a07dd14 100755 --- a/config.ru +++ b/config.ru @@ -11,6 +11,19 @@ map '/lobster' do run Rack::Lobster.new end +map '/headers' do + headers = proc do |env| + [200, { "Content-Type" => "text/html" }, [ + env.select {|key,val| key.start_with? 'HTTP_'} + .collect {|key, val| [key.sub(/^HTTP_/, ''), val]} + .collect {|key, val| CGI::escapeHTML "#{key}: #{val}"} + .sort + .join("
\n") + ]] + end + run headers +end + map '/' do welcome = proc do |env| [200, { "Content-Type" => "text/html" }, [<