Class: Rack::Handler::SCGI
- Defined in:
- lib/gems/rack-0.9.1/lib/rack/handler/scgi.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(settings = {}) ⇒ SCGI
constructor
A new instance of SCGI.
- #process_request(request, input_body, socket) ⇒ Object
Constructor Details
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
7 8 9 |
# File 'lib/gems/rack-0.9.1/lib/rack/handler/scgi.rb', line 7 def app @app end |
Class Method Details
.error(*args) ⇒ Object
20 |
# File 'lib/gems/rack-0.9.1/lib/rack/handler/scgi.rb', line 20 def @log.error(*args); end |
.info(*args) ⇒ Object
19 |
# File 'lib/gems/rack-0.9.1/lib/rack/handler/scgi.rb', line 19 def @log.info(*args); end |
.run(app, options = nil) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/gems/rack-0.9.1/lib/rack/handler/scgi.rb', line 9 def self.run(app, =nil) new(.merge(:app=>app, :host=>[:Host], :port=>[:Port], :socket=>[:Socket])).listen end |
Instance Method Details
#process_request(request, input_body, socket) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/gems/rack-0.9.1/lib/rack/handler/scgi.rb', line 24 def process_request(request, input_body, socket) env = {}.replace(request) env.delete "HTTP_CONTENT_TYPE" env.delete "HTTP_CONTENT_LENGTH" env["REQUEST_PATH"], env["QUERY_STRING"] = env["REQUEST_URI"].split('?', 2) env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] env["PATH_INFO"] = env["REQUEST_PATH"] env["QUERY_STRING"] ||= "" env["SCRIPT_NAME"] = "" env.update({"rack.version" => [0,1], "rack.input" => StringIO.new(input_body), "rack.errors" => STDERR, "rack.multithread" => true, "rack.multiprocess" => true, "rack.run_once" => false, "rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http" }) status, headers, body = app.call(env) begin socket.write("Status: #{status}\r\n") headers.each do |k, vs| vs.each {|v| socket.write("#{k}: #{v}\r\n")} end socket.write("\r\n") body.each {|s| socket.write(s)} ensure body.close if body.respond_to? :close end end |