Parent

Class Index [+]

Quicksearch

Rack::Handler::FastCGI

Public Class Methods

run(app, options={}) click to toggle source
    # File lib/rack/handler/fastcgi.rb, line 21
21:       def self.run(app, options={})
22:         if options[:File]
23:           STDIN.reopen(UNIXServer.new(options[:File]))
24:         elsif options[:Port]
25:           STDIN.reopen(TCPServer.new(options[:Host], options[:Port]))
26:         end
27:         FCGI.each { |request|
28:           serve request, app
29:         }
30:       end
send_body(out, body) click to toggle source
    # File lib/rack/handler/fastcgi.rb, line 90
90:       def self.send_body(out, body)
91:         body.each { |part|
92:           out.print part
93:           out.flush
94:         }
95:       end
send_headers(out, status, headers) click to toggle source
    # File lib/rack/handler/fastcgi.rb, line 79
79:       def self.send_headers(out, status, headers)
80:         out.print "Status: #{status}\r\n"
81:         headers.each { |k, vs|
82:           vs.split("\n").each { |v|
83:             out.print "#{k}: #{v}\r\n"
84:           }
85:         }
86:         out.print "\r\n"
87:         out.flush
88:       end
serve(request, app) click to toggle source
    # File lib/rack/handler/fastcgi.rb, line 40
40:       def self.serve(request, app)
41:         env = request.env
42:         env.delete "HTTP_CONTENT_LENGTH"
43: 
44:         env["SCRIPT_NAME"] = ""  if env["SCRIPT_NAME"] == "/"
45: 
46:         rack_input = RewindableInput.new(request.in)
47: 
48:         env.update({"rack.version" => Rack::VERSION,
49:                      "rack.input" => rack_input,
50:                      "rack.errors" => request.err,
51: 
52:                      "rack.multithread" => false,
53:                      "rack.multiprocess" => true,
54:                      "rack.run_once" => false,
55: 
56:                      "rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http"
57:                    })
58: 
59:         env["QUERY_STRING"] ||= ""
60:         env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
61:         env["REQUEST_PATH"] ||= "/"
62:         env.delete "CONTENT_TYPE"  if env["CONTENT_TYPE"] == ""
63:         env.delete "CONTENT_LENGTH"  if env["CONTENT_LENGTH"] == ""
64: 
65:         begin
66:           status, headers, body = app.call(env)
67:           begin
68:             send_headers request.out, status, headers
69:             send_body request.out, body
70:           ensure
71:             body.close  if body.respond_to? :close
72:           end
73:         ensure
74:           rack_input.close
75:           request.finish
76:         end
77:       end
valid_options() click to toggle source
    # File lib/rack/handler/fastcgi.rb, line 32
32:       def self.valid_options
33:         {
34:           "Host=HOST" => "Hostname to listen on (default: localhost)",
35:           "Port=PORT" => "Port to listen on (default: 8080)",
36:           "File=PATH" => "Creates a Domain socket at PATH instead of a TCP socket. Ignores Host and Port if set.",
37:         }
38:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.