about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorIan Ownbey <imownbey@ian-ownbeys-macbook.local>2008-12-04 15:36:59 -0800
committerIan Ownbey <imownbey@ian-ownbeys-macbook.local>2008-12-04 15:36:59 -0800
commit0d838c607c0c709e5190b24aff116306f4d02255 (patch)
treedb320ff03c183bfd8858fc1b387f0302f208cbae /lib
parenta5b87dcbe64f4fbfd7733e8762ec7b843ca7d39b (diff)
downloadunicorn-0d838c607c0c709e5190b24aff116306f4d02255.tar.gz
Diffstat (limited to 'lib')
-rw-r--r--lib/mongrel.rb9
-rw-r--r--lib/mongrel/uri_classifier.rb76
2 files changed, 2 insertions, 83 deletions
diff --git a/lib/mongrel.rb b/lib/mongrel.rb
index 251e2d4..e0c2b01 100644
--- a/lib/mongrel.rb
+++ b/lib/mongrel.rb
@@ -24,7 +24,6 @@ require 'mongrel/cgi'
 require 'mongrel/handlers'
 require 'mongrel/command'
 require 'mongrel/tcphack'
-require 'mongrel/uri_classifier'
 require 'mongrel/const'
 require 'mongrel/http_request'
 require 'mongrel/header_out'
@@ -94,7 +93,6 @@ module Mongrel
       if defined?(Fcntl::FD_CLOEXEC)
         @socket.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
       end
-      @classifier = URIClassifier.new
       @host = host
       @port = port
       @workers = ThreadGroup.new
@@ -134,11 +132,8 @@ module Mongrel
 
             raise "No REQUEST PATH" if not params[Const::REQUEST_PATH]
 
-
-            script_name, path_info, handlers = @classifier.resolve(params[Const::REQUEST_PATH])
-
-            params[Const::PATH_INFO] = path_info
-            params[Const::SCRIPT_NAME] = script_name
+            params[Const::PATH_INFO] = params[Const::REQUEST_PATH]
+            params[Const::SCRIPT_NAME] = Const::SLASH
 
             # From http://www.ietf.org/rfc/rfc3875 :
             # "Script authors should be aware that the REMOTE_ADDR and REMOTE_HOST
diff --git a/lib/mongrel/uri_classifier.rb b/lib/mongrel/uri_classifier.rb
deleted file mode 100644
index f39ccc9..0000000
--- a/lib/mongrel/uri_classifier.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-
-module Mongrel
-  class URIClassifier
-  
-    class RegistrationError < RuntimeError
-    end
-    class UsageError < RuntimeError
-    end
-
-    attr_reader :handler_map  
-
-    # Returns the URIs that have been registered with this classifier so far.
-    def uris
-      @handler_map.keys
-    end
-
-    def initialize
-      @handler_map = {}
-      @matcher = //
-      @root_handler = nil
-    end
-    
-    # Register a handler object at a particular URI. The handler can be whatever
-    # you want, including an array. It's up to you what to do with it.
-    #
-    # Registering a handler is not necessarily threadsafe, so be careful if you go
-    # mucking around once the server is running.
-    def register(uri, handler)
-      raise RegistrationError, "#{uri.inspect} is already registered" if @handler_map[uri]
-      raise RegistrationError, "URI is empty" if !uri or uri.empty?
-      raise RegistrationError, "URI must begin with a \"#{Const::SLASH}\"" unless uri[0..0] == Const::SLASH
-      @handler_map[uri.dup] = handler
-      rebuild
-    end
-    
-    # Unregister a particular URI and its handler.
-    def unregister(uri)
-      handler = @handler_map.delete(uri)
-      raise RegistrationError, "#{uri.inspect} was not registered" unless handler
-      rebuild
-      handler
-    end
-    
-    # Resolve a request URI by finding the best partial match in the registered
-    # handler URIs.
-    def resolve(request_uri)
-      if @root_handler
-        # Optimization for the pathological case of only one handler on "/"; e.g. Rails
-        [Const::SLASH, request_uri, @root_handler]
-      elsif match = @matcher.match(request_uri)
-        uri = match.to_s
-        # A root mounted ("/") handler must resolve such that path info matches the original URI.
-        [uri, (uri == Const::SLASH ? request_uri : match.post_match), @handler_map[uri]]
-      else
-        [nil, nil, nil]
-      end
-    end
-        
-    private
-    
-    def rebuild
-      if @handler_map.size == 1 and @handler_map[Const::SLASH]
-        @root_handler = @handler_map.values.first
-      else
-        @root_handler = nil
-        routes = @handler_map.keys.sort.sort_by do |uri|
-          -uri.length
-        end
-        @matcher = Regexp.new(routes.map do |uri|
-          Regexp.new('^' + Regexp.escape(uri))
-        end.join('|'))
-      end
-    end    
-    
-  end
-end \ No newline at end of file