Class Rack::Handler::FastCGI
In: lib/rack/handler/fastcgi.rb
Parent: Object

Methods

run   send_body   send_headers   serve  

Public Class methods

[Source]

    # File lib/rack/handler/fastcgi.rb, line 6
 6:       def self.run(app, options={})
 7:         file = options[:File] and STDIN.reopen(UNIXServer.new(file))
 8:         port = options[:Port] and STDIN.reopen(TCPServer.new(port))
 9:         FCGI.each { |request|
10:           serve request, app
11:         }
12:       end

[Source]

    # File lib/rack/handler/fastcgi.rb, line 75
75:       def self.send_body(out, body)
76:         body.each { |part|
77:           out.print part
78:           out.flush
79:         }
80:       end

[Source]

    # File lib/rack/handler/fastcgi.rb, line 64
64:       def self.send_headers(out, status, headers)
65:         out.print "Status: #{status}\r\n"
66:         headers.each { |k, vs|
67:           vs.each { |v|
68:             out.print "#{k}: #{v}\r\n"
69:           }
70:         }
71:         out.print "\r\n"
72:         out.flush
73:       end

[Source]

    # File lib/rack/handler/fastcgi.rb, line 30
30:       def self.serve(request, app)
31:         env = request.env
32:         env.delete "HTTP_CONTENT_LENGTH"
33: 
34:         request.in.extend ProperStream
35: 
36:         env["SCRIPT_NAME"] = ""  if env["SCRIPT_NAME"] == "/"
37: 
38:         env.update({"rack.version" => [0,1],
39:                      "rack.input" => request.in,
40:                      "rack.errors" => request.err,
41: 
42:                      "rack.multithread" => false,
43:                      "rack.multiprocess" => true,
44:                      "rack.run_once" => false,
45: 
46:                      "rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http"
47:                    })
48: 
49:         env["QUERY_STRING"] ||= ""
50:         env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
51:         env["REQUEST_PATH"] ||= "/"
52:         env.delete "PATH_INFO"  if env["PATH_INFO"] == ""
53: 
54:         status, headers, body = app.call(env)
55:         begin
56:           send_headers request.out, status, headers
57:           send_body request.out, body
58:         ensure
59:           body.close  if body.respond_to? :close
60:           request.finish
61:         end
62:       end

[Validate]