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