Sha256: 8bf563a409e9c5d0fc4613dba1b2d05476c681c5113e2fc2d8242b75184f4448
Contents?: true
Size: 951 Bytes
Versions: 3
Compression:
Stored size: 951 Bytes
Contents
require 'rubygems' require 'rack' module HttpLogger module Test class Server def call(env) @root = File.expand_path(File.dirname(__FILE__)) path = Rack::Utils.unescape(env['PATH_INFO']) path += 'index.html' if path == '/' file = @root + "#{path}" params = Rack::Utils.parse_nested_query(env['QUERY_STRING']) headers = {"Content-Type" => "text/html"} if params['redirect'] [ 301, {"Location" => "/index.html"}, '' ] elsif File.exists?(file) headers["Content-Type"] = "application/octet-stream" if File.extname(file) == '.bin' headers["Content-Type"] = "text/html; charset=UTF-8" if path =~ /utf8/ headers["Content-Encoding"] = "gzip" if File.extname(file) == '.gz' [ 200, headers, File.binread(file) ] else [ 404, {'Content-Type' => 'text/plain'}, 'file not found' ] end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
binnacle-0.5.0 | spec/support/test_server.rb |
binnacle-0.4.9 | spec/support/test_server.rb |
binnacle-0.4.8 | spec/support/test_server.rb |