Created
March 22, 2010 03:04
-
-
Save postmodern/339764 to your computer and use it in GitHub Desktop.
Please stop writing your own HTTP parsers, consider Rack next time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rack' | |
FILES = { | |
'/index.html' => 'index.html' | |
} | |
Rack::Handler.get('Thin').run proc { |env| | |
path = env['PATH_INFO'] | |
if FILES[path] | |
[200, {'Content-Type' => 'octet/stream'}, File.new(FILES[path])] | |
else | |
[400, {'Content-Type' => 'text/html'}, ['Fail']] | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment