(Not documented)
# File lib/rack/handler/mongrel.rb, line 37 37: def initialize(app) 38: @app = Rack::Chunked.new(Rack::ContentLength.new(app)) 39: end
(Not documented)
# File lib/rack/handler/mongrel.rb, line 9 9: def self.run(app, options={}) 10: server = ::Mongrel::HttpServer.new(options[:Host] || '0.0.0.0', 11: options[:Port] || 8080) 12: # Acts like Rack::URLMap, utilizing Mongrel's own path finding methods. 13: # Use is similar to #run, replacing the app argument with a hash of 14: # { path=>app, ... } or an instance of Rack::URLMap. 15: if options[:map] 16: if app.is_a? Hash 17: app.each do |path, appl| 18: path = '/'+path unless path[0] == ?/ 19: server.register(path, Rack::Handler::Mongrel.new(appl)) 20: end 21: elsif app.is_a? URLMap 22: app.instance_variable_get(:@mapping).each do |(host, path, appl)| 23: next if !host.nil? && !options[:Host].nil? && options[:Host] != host 24: path = '/'+path unless path[0] == ?/ 25: server.register(path, Rack::Handler::Mongrel.new(appl)) 26: end 27: else 28: raise ArgumentError, "first argument should be a Hash or URLMap" 29: end 30: else 31: server.register('/', Rack::Handler::Mongrel.new(app)) 32: end 33: yield server if block_given? 34: server.run.join 35: end
(Not documented)
# File lib/rack/handler/mongrel.rb, line 41 41: def process(request, response) 42: env = {}.replace(request.params) 43: env.delete "HTTP_CONTENT_TYPE" 44: env.delete "HTTP_CONTENT_LENGTH" 45: 46: env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/" 47: 48: rack_input = request.body || StringIO.new('') 49: rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding) 50: 51: env.update({"rack.version" => [1,0], 52: "rack.input" => rack_input, 53: "rack.errors" => $stderr, 54: 55: "rack.multithread" => true, 56: "rack.multiprocess" => false, # ??? 57: "rack.run_once" => false, 58: 59: "rack.url_scheme" => "http", 60: }) 61: env["QUERY_STRING"] ||= "" 62: env.delete "PATH_INFO" if env["PATH_INFO"] == "" 63: 64: status, headers, body = @app.call(env) 65: 66: begin 67: response.status = status.to_i 68: response.send_status(nil) 69: 70: headers.each { |k, vs| 71: vs.split("\n").each { |v| 72: response.header[k] = v 73: } 74: } 75: response.send_header 76: 77: body.each { |part| 78: response.write part 79: response.socket.flush 80: } 81: ensure 82: body.close if body.respond_to? :close 83: end 84: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.