aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/webrick_server.rb
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-10-16 03:00:44 +0000
committerJamis Buck <jamis@37signals.com>2005-10-16 03:00:44 +0000
commitae294afa8d0a68d39613382d84cfba8821e48e38 (patch)
tree74891cc3c6609f147cbc138a9340e8b8bc384cf4 /railties/lib/webrick_server.rb
parent1ea085ec7e77af32bf5234fb4642b012aec62779 (diff)
downloadrails-ae294afa8d0a68d39613382d84cfba8821e48e38.tar.gz
rails-ae294afa8d0a68d39613382d84cfba8821e48e38.tar.bz2
rails-ae294afa8d0a68d39613382d84cfba8821e48e38.zip
Documentation updates/fixes for railties
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2637 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/webrick_server.rb')
-rw-r--r--railties/lib/webrick_server.rb17
1 files changed, 12 insertions, 5 deletions
diff --git a/railties/lib/webrick_server.rb b/railties/lib/webrick_server.rb
index 734f87f6fd..f356eaf35e 100644
--- a/railties/lib/webrick_server.rb
+++ b/railties/lib/webrick_server.rb
@@ -10,7 +10,7 @@ ABSOLUTE_RAILS_ROOT = File.expand_path(RAILS_ROOT)
ActiveRecord::Base.threaded_connections = false
-class CGI
+class CGI #:nodoc:
def stdinput
@stdin || $stdin
end
@@ -40,9 +40,16 @@ class CGI
end
end
+# A custom dispatch servlet for use with WEBrick. It dispatches requests
+# (using the Rails Dispatcher) to the appropriate controller/action. By default,
+# it restricts WEBrick to a managing a single Rails request at a time, but you
+# can change this behavior by setting ActionController::Base.allow_concurrency
+# to true.
class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
REQUEST_MUTEX = Mutex.new
+ # Start the WEBrick server with the given options, mounting the
+ # DispatchServlet at <tt>/</tt>.
def self.dispatch(options = {})
Socket.do_not_reverse_lookup = true # patch for OS X
@@ -62,14 +69,14 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
server.start
end
- def initialize(server, options)
+ def initialize(server, options) #:nodoc:
@server_options = options
@file_handler = WEBrick::HTTPServlet::FileHandler.new(server, options[:server_root])
Dir.chdir(ABSOLUTE_RAILS_ROOT)
super
end
- def service(req, res)
+ def service(req, res) #:nodoc:
begin
unless handle_file(req, res)
REQUEST_MUTEX.lock unless ActionController::Base.allow_concurrency
@@ -84,7 +91,7 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
end
end
- def handle_file(req, res)
+ def handle_file(req, res) #:nodoc:
begin
req = req.dup
path = req.path.dup
@@ -105,7 +112,7 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
end
end
- def handle_dispatch(req, res, origin = nil)
+ def handle_dispatch(req, res, origin = nil) #:nodoc:
data = StringIO.new
Dispatcher.dispatch(
CGI.new("query", create_env_table(req, origin), StringIO.new(req.body || "")),