Class | Mongrel::DirHandler |
In: |
lib/mongrel/handlers.rb
|
Parent: | HttpHandler |
Serves the contents of a directory. You give it the path to the root where the files are located, and it tries to find the files based on the PATH_INFO inside the directory. If the requested path is a directory then it returns a simple directory listing.
It does a simple protection against going outside it’s root path by converting all paths to an absolute expanded path, and then making sure that the final expanded path includes the root path. If it doesn’t than it simply gives a 404.
MIME_TYPES | = | { ".css" => "text/css", ".gif" => "image/gif", ".htm" => "text/html", ".html" => "text/html", ".jpeg" => "image/jpeg", ".jpg" => "image/jpeg", ".js" => "text/javascript", ".png" => "image/png", ".swf" => "application/x-shockwave-flash", ".txt" => "text/plain" |
ONLY_HEAD_GET | = | "Only HEAD and GET allowed.".freeze |
path | [R] |
There is a small number of default mime types for extensions, but this lets you add any others you’ll need when serving content.
Process the request to either serve a file or a directory listing if allowed (based on the listing_allowed paramter to the constructor).
Returns a simplistic directory listing if they’re enabled, otherwise a 403. Base is the base URI from the REQUEST_URI, dir is the directory to serve on the file system (comes from can_serve()), and response is the HttpResponse object to send the results on.