Class: PHPRPC::SCGIProcessor
- Inherits:
-
SCGI::Processor
- Object
- SCGI::Processor
- PHPRPC::SCGIProcessor
- Defined in:
- lib/phprpc/scgi_server.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ SCGIProcessor
constructor
A new instance of SCGIProcessor.
- #process_request(request, input_body, socket) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SCGIProcessor
Returns a new instance of SCGIProcessor.
39 40 41 42 43 44 45 46 47 |
# File 'lib/phprpc/scgi_server.rb', line 39 def initialize( = {}) @app = [:app] if not .key?(:logfile) then @log = Object.new def @log.info(*args); end def @log.error(*args); end end super() end |
Instance Method Details
#process_request(request, input_body, socket) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/phprpc/scgi_server.rb', line 49 def process_request(request, input_body, socket) env = {}.replace(request) env["REQUEST_PATH"], env["QUERY_STRING"] = env["REQUEST_URI"].split('?', 2) env["QUERY_STRING"] ||= "" env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] env["SCRIPT_NAME"] = env["PATH_INFO"] = env["REQUEST_PATH"] env["rack.input"] = StringIO.new(input_body) env["rack.multithread"] = true # this variable only used for rack pool session on debug mode env["rack.url_scheme"] = ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http" status, headers, body = @app.call(env) socket.write("Status: #{status}\r\n") headers.each { |k, v| socket.write("#{k}: #{v}\r\n") } socket.write("\r\n") socket.write(body) end |