Skip to content

Instantly share code, notes, and snippets.

@pglombardo
Created October 25, 2013 19:35
Show Gist options
  • Save pglombardo/7160574 to your computer and use it in GitHub Desktop.
Save pglombardo/7160574 to your computer and use it in GitHub Desktop.
Custom Rack Stack that Dumps Request Headers
# Taken from: http://stackoverflow.com/a/6318491
require 'rack'
app = Proc.new do |env|
headers = env.select {|k,v| k.start_with? 'HTTP_'}
.collect {|pair| [pair[0].sub(/^HTTP_/, ''), pair[1]]}
.collect {|pair| pair.join(": ") << "<br>"}
.sort
[200, {'Content-Type' => 'text/html'}, headers]
end
Rack::Server.start :app => app, :Port => 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment