Class Rack::Handler::SCGI
In: lib/rack/handler/scgi.rb
Parent: ::SCGI::Processor

Methods

new   process_request   run  

Attributes

app  [RW] 

Public Class methods

[Source]

    # File lib/rack/handler/scgi.rb, line 16
16:       def initialize(settings = {})
17:         @app = settings[:app]
18:         @log = Object.new
19:         def @log.info(*args); end
20:         def @log.error(*args); end
21:         super(settings)
22:       end

[Source]

    # File lib/rack/handler/scgi.rb, line 9
 9:       def self.run(app, options=nil)
10:         new(options.merge(:app=>app,
11:                           :host=>options[:Host],
12:                           :port=>options[:Port],
13:                           :socket=>options[:Socket])).listen
14:       end

Public Instance methods

[Source]

    # File lib/rack/handler/scgi.rb, line 24
24:       def   process_requestprocess_requestprocess_request(request, input_body, socket)
25:         env = {}.replace(request)
26:         env.delete "HTTP_CONTENT_TYPE"
27:         env.delete "HTTP_CONTENT_LENGTH"
28:         env["REQUEST_PATH"], env["QUERY_STRING"] = env["REQUEST_URI"].split('?', 2)
29:         env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
30:         env["PATH_INFO"] = env["REQUEST_PATH"]
31:         env["QUERY_STRING"] ||= ""
32:         env["SCRIPT_NAME"] = ""
33:         env.update({"rack.version" => [0,1],
34:                      "rack.input" => StringIO.new(input_body),
35:                      "rack.errors" => STDERR,
36: 
37:                      "rack.multithread" => true,
38:                      "rack.multiprocess" => true,
39:                      "rack.run_once" => false,
40: 
41:                      "rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http"
42:                    })
43:         status, headers, body = app.call(env)
44:         begin
45:           socket.write("Status: #{status}\r\n")
46:           headers.each do |k, vs|
47:             vs.each {|v| socket.write("#{k}: #{v}\r\n")}
48:           end
49:           socket.write("\r\n")
50:           body.each {|s| socket.write(s)}
51:         ensure
52:           body.close if body.respond_to? :close
53:         end
54:       end

[Validate]