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

Methods

run   send_body   send_headers   serve  

Classes and Modules

Module Rack::Handler::FastCGI::ProperStream

Public Class methods

[Source]

    # File lib/rack/handler/fastcgi.rb, line 6
 6:       def self.run(app, options=nil)
 7:         FCGI.each { |request|
 8:           serve request, app
 9:         }
10:       end

[Source]

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

[Source]

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

[Source]

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

[Validate]