Parent

Class Index [+]

Quicksearch

Rack::Handler::CGI

Public Class Methods

run(app, options=nil) click to toggle source
    # File lib/rack/handler/cgi.rb, line 7
 7:       def self.run(app, options=nil)
 8:         $stdin.binmode
 9:         serve app
10:       end
send_body(body) click to toggle source
    # File lib/rack/handler/cgi.rb, line 55
55:       def self.send_body(body)
56:         body.each { |part|
57:           $stdout.print part
58:           $stdout.flush
59:         }
60:       end
send_headers(status, headers) click to toggle source
    # File lib/rack/handler/cgi.rb, line 44
44:       def self.send_headers(status, headers)
45:         $stdout.print "Status: #{status}\r\n"
46:         headers.each { |k, vs|
47:           vs.split("\n").each { |v|
48:             $stdout.print "#{k}: #{v}\r\n"
49:           }
50:         }
51:         $stdout.print "\r\n"
52:         $stdout.flush
53:       end
serve(app) click to toggle source
    # File lib/rack/handler/cgi.rb, line 12
12:       def self.serve(app)
13:         app = ContentLength.new(app)
14: 
15:         env = ENV.to_hash
16:         env.delete "HTTP_CONTENT_LENGTH"
17: 
18:         env["SCRIPT_NAME"] = ""  if env["SCRIPT_NAME"] == "/"
19: 
20:         env.update({"rack.version" => Rack::VERSION,
21:                      "rack.input" => Rack::RewindableInput.new($stdin),
22:                      "rack.errors" => $stderr,
23: 
24:                      "rack.multithread" => false,
25:                      "rack.multiprocess" => true,
26:                      "rack.run_once" => true,
27: 
28:                      "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
29:                    })
30: 
31:         env["QUERY_STRING"] ||= ""
32:         env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
33:         env["REQUEST_PATH"] ||= "/"
34: 
35:         status, headers, body = app.call(env)
36:         begin
37:           send_headers status, headers
38:           send_body body
39:         ensure
40:           body.close  if body.respond_to? :close
41:         end
42:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.