Parent

Class Index [+]

Quicksearch

Rack::Handler::CGI

Public Class Methods

run(app, options=nil) click to toggle source

(Not documented)

   # File lib/rack/handler/cgi.rb, line 6
6:       def self.run(app, options=nil)
7:         serve app
8:       end
send_body(body) click to toggle source

(Not documented)

    # File lib/rack/handler/cgi.rb, line 53
53:       def self.send_body(body)
54:         body.each { |part|
55:           STDOUT.print part
56:           STDOUT.flush
57:         }
58:       end
send_headers(status, headers) click to toggle source

(Not documented)

    # File lib/rack/handler/cgi.rb, line 42
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"
47:           }
48:         }
49:         STDOUT.print "\r\n"
50:         STDOUT.flush
51:       end
serve(app) click to toggle source

(Not documented)

    # File lib/rack/handler/cgi.rb, line 10
10:       def self.serve(app)
11:         app = ContentLength.new(app)
12: 
13:         env = ENV.to_hash
14:         env.delete "HTTP_CONTENT_LENGTH"
15: 
16:         env["SCRIPT_NAME"] = ""  if env["SCRIPT_NAME"] == "/"
17: 
18:         env.update({"rack.version" => [1,1],
19:                      "rack.input" => $stdin,
20:                      "rack.errors" => $stderr,
21: 
22:                      "rack.multithread" => false,
23:                      "rack.multiprocess" => true,
24:                      "rack.run_once" => true,
25: 
26:                      "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
27:                    })
28: 
29:         env["QUERY_STRING"] ||= ""
30:         env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
31:         env["REQUEST_PATH"] ||= "/"
32: 
33:         status, headers, body = app.call(env)
34:         begin
35:           send_headers status, headers
36:           send_body body
37:         ensure
38:           body.close  if body.respond_to? :close
39:         end
40:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.