2 require 'rack/content_length'
7 def self.run(app
, options
=nil)
8 while LSAPI
.accept
!= nil
13 app
= Rack
::ContentLength.new(app
)
16 env.delete
"HTTP_CONTENT_LENGTH"
17 env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
18 env.update({"rack.version" => [0,1],
19 "rack.input" => StringIO
.new($stdin.read
.to_s
),
20 "rack.errors" => $stderr,
21 "rack.multithread" => false,
22 "rack.multiprocess" => true,
23 "rack.run_once" => false,
24 "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
26 env["QUERY_STRING"] ||= ""
27 env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
28 env["REQUEST_PATH"] ||= "/"
29 status
, headers
, body
= app
.call(env)
31 send_headers status
, headers
34 body
.close
if body
.respond_to
? :close
37 def self.send_headers(status
, headers
)
38 print
"Status: #{status}\r\n"
39 headers
.each
{ |k
, vs
|
40 vs
.split("\n").each
{ |v
|
41 print
"#{k}: #{v}\r\n"
47 def self.send_body(body
)