about summary refs log tree commit homepage
path: root/lib/mongrel
diff options
context:
space:
mode:
authorevanweaver <evanweaver@19e92222-5c0b-0410-8929-a290d50e31e9>2007-10-26 02:01:39 +0000
committerevanweaver <evanweaver@19e92222-5c0b-0410-8929-a290d50e31e9>2007-10-26 02:01:39 +0000
commit14fc77f607e47f2adf77b31457d0c8a7a3300af6 (patch)
tree27de986f3aaf896f94fd0ec2d5d96be9eb07720c /lib/mongrel
parent30b725ffd76a5b99ae44ff148c5bdf30d00607c1 (diff)
downloadunicorn-14fc77f607e47f2adf77b31457d0c8a7a3300af6.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@739 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'lib/mongrel')
-rw-r--r--lib/mongrel/handlers.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/mongrel/handlers.rb b/lib/mongrel/handlers.rb
index 05f585c..9981a18 100644
--- a/lib/mongrel/handlers.rb
+++ b/lib/mongrel/handlers.rb
@@ -98,6 +98,10 @@ module Mongrel
   # that the final expanded path includes the root path.  If it doesn't
   # than it simply gives a 404.
   #
+  # If you pass nil as the root path, it will not check any locations or
+  # expand any paths. This lets you serve files from multiple directories
+  # on win32.
+  #
   # The default content type is "text/plain; charset=ISO-8859-1" but you
   # can change it anything you want using the DirHandler.default_content_type
   # attribute.
@@ -110,9 +114,9 @@ module Mongrel
 
     ONLY_HEAD_GET="Only HEAD and GET allowed.".freeze
 
-    # You give it the path to the directory root and an (optional)
+    # You give it the path to the directory root and and optional listing_allowed and index_html
     def initialize(path, listing_allowed=true, index_html="index.html")
-      @path = File.expand_path(path)
+      @path = File.expand_path(path) if path
       @listing_allowed=listing_allowed
       @index_html = index_html
       @default_content_type = "application/octet-stream".freeze
@@ -120,7 +124,13 @@ module Mongrel
 
     # Checks if the given path can be served and returns the full path (or nil if not).
     def can_serve(path_info)
-      req_path = File.expand_path(File.join(@path,HttpRequest.unescape(path_info)), @path)
+
+      req_path = HttpRequest.unescape(path_info)
+      if @path
+        req_path = File.expand_path(File.join(@path, path_info), @path)
+      else
+        req_path = File.expand_path(req_path)
+      end
 
       if req_path.index(@path) == 0 and File.exist? req_path
         # it exists and it's in the right location