Skip to content

Instantly share code, notes, and snippets.

@YoshitsuguFujii
Created January 5, 2015 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YoshitsuguFujii/7fe7127b33eae050c20e to your computer and use it in GitHub Desktop.
Save YoshitsuguFujii/7fe7127b33eae050c20e to your computer and use it in GitHub Desktop.
# http://stackoverflow.com/questions/6317705/rackrequest-how-do-i-get-all-headers
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