summary refs log tree commit
path: root/lib/rack/handler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rack/handler.rb')
-rw-r--r--lib/rack/handler.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/rack/handler.rb b/lib/rack/handler.rb
index 5624a1e7..3c09883e 100644
--- a/lib/rack/handler.rb
+++ b/lib/rack/handler.rb
@@ -22,6 +22,25 @@ module Rack
       end
     end
 
+    def self.default(options = {})
+      # Guess.
+      if ENV.include?("PHP_FCGI_CHILDREN")
+        # We already speak FastCGI
+        options.delete :File
+        options.delete :Port
+
+        Rack::Handler::FastCGI
+      elsif ENV.include?("REQUEST_METHOD")
+        Rack::Handler::CGI
+      else
+        begin
+          Rack::Handler::Mongrel
+        rescue LoadError => e
+          Rack::Handler::WEBrick
+        end
+      end
+    end
+
     # Transforms server-name constants to their canonical form as filenames,
     # then tries to require them but silences the LoadError if not found
     #