1 require 'rack/content_length'
6 def self.run(app
, options
=nil)
11 app
= ContentLength
.new(app
)
14 env.delete
"HTTP_CONTENT_LENGTH"
16 env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
18 env.update({"rack.version" => [0,1],
19 "rack.input" => $stdin,
20 "rack.errors" => $stderr,
22 "rack.multithread" => false,
23 "rack.multiprocess" => true,
24 "rack.run_once" => true,
26 "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
29 env["QUERY_STRING"] ||= ""
30 env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
31 env["REQUEST_PATH"] ||= "/"
33 status
, headers
, body
= app
.call(env)
35 send_headers status
, headers
38 body
.close
if body
.respond_to
? :close
42 def self.send_headers(status
, headers
)
43 STDOUT.print
"Status: #{status}\r\n"
44 headers
.each
{ |k
, vs
|
45 vs
.split("\n").each
{ |v
|
46 STDOUT.print
"#{k}: #{v}\r\n"
53 def self.send_body(body
)