Parent

Class Index [+]

Quicksearch

Rack::Handler::SCGI

Attributes

app[RW]

(Not documented)

Public Class Methods

new(settings = {}) click to toggle source

(Not documented)

    # File lib/rack/handler/scgi.rb, line 18
18:       def initialize(settings = {})
19:         @app = Rack::Chunked.new(Rack::ContentLength.new(settings[:app]))
20:         @log = Object.new
21:         def @log.info(*args); end
22:         def @log.error(*args); end
23:         super(settings)
24:       end
run(app, options=nil) click to toggle source

(Not documented)

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

Public Instance Methods

process_request(request, input_body, socket) click to toggle source

(Not documented)

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.