From 5ce019b7424ff41688d983f3a792c7788a2e71a3 Mon Sep 17 00:00:00 2001 From: Aleksandar Kostadinov Date: Thu, 14 Sep 2017 03:52:14 +0800 Subject: [PATCH] allow viewing request headers (#8) * allow viewing request headers * text/plain output for headers --- config.ru | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config.ru b/config.ru index a709f06..0c274dc 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/plain" }, [ + env.select {|key,val| key.start_with? 'HTTP_'} + .collect {|key, val| [key.sub(/^HTTP_/, ''), val]} + .collect {|key, val| "#{key}: #{val}"} + .sort + .join("\n") + ]] + end + run headers +end + map '/' do welcome = proc do |env| [200, { "Content-Type" => "text/html" }, [<