aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/mongrel_server/handler.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-12-07 03:05:03 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-12-07 03:05:03 +0100
commit8f1c229571b4db8dda144bf6eaa193799309e817 (patch)
tree592710207a614428d5cb809f6e13c8b546b58969 /railties/lib/rails/mongrel_server/handler.rb
parent601e40e744f44fe8819be100a8c472ea161d13ab (diff)
parent9eca588bdfbb41f6b48477025d1cd8eea4a38296 (diff)
downloadrails-8f1c229571b4db8dda144bf6eaa193799309e817.tar.gz
rails-8f1c229571b4db8dda144bf6eaa193799309e817.tar.bz2
rails-8f1c229571b4db8dda144bf6eaa193799309e817.zip
Merge commit 'mainstream/master'
Conflicts: actionmailer/lib/action_mailer/base.rb actionpack/lib/action_controller/base.rb actionpack/lib/action_controller/mime_type.rb railties/doc/guides/html/activerecord_validations_callbacks.html railties/doc/guides/html/caching_with_rails.html railties/doc/guides/html/command_line.html railties/doc/guides/html/configuring.html railties/doc/guides/html/creating_plugins.html railties/doc/guides/html/finders.html railties/doc/guides/html/routing_outside_in.html railties/doc/guides/source/activerecord_validations_callbacks.txt railties/doc/guides/source/caching_with_rails.txt railties/doc/guides/source/command_line.txt railties/doc/guides/source/creating_plugins/acts_as_yaffle.txt railties/doc/guides/source/creating_plugins/controllers.txt railties/doc/guides/source/creating_plugins/core_ext.txt railties/doc/guides/source/creating_plugins/helpers.txt railties/doc/guides/source/creating_plugins/index.txt railties/doc/guides/source/creating_plugins/migration_generator.txt railties/doc/guides/source/creating_plugins/models.txt railties/doc/guides/source/creating_plugins/odds_and_ends.txt railties/doc/guides/source/creating_plugins/routes.txt railties/doc/guides/source/finders.txt railties/doc/guides/source/routing_outside_in.txt railties/doc/guides/source/testing_rails_applications.txt
Diffstat (limited to 'railties/lib/rails/mongrel_server/handler.rb')
-rw-r--r--railties/lib/rails/mongrel_server/handler.rb55
1 files changed, 0 insertions, 55 deletions
diff --git a/railties/lib/rails/mongrel_server/handler.rb b/railties/lib/rails/mongrel_server/handler.rb
deleted file mode 100644
index a19eca7259..0000000000
--- a/railties/lib/rails/mongrel_server/handler.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright (c) 2005 Zed A. Shaw
-# You can redistribute it and/or modify it under the same terms as Ruby.
-#
-# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
-# for more information.
-
-require 'mongrel'
-require 'cgi'
-require 'action_controller/dispatcher'
-
-
-module Rails
- module MongrelServer
- # Implements a handler that can run Rails and serve files out of the
- # Rails application's public directory. This lets you run your Rails
- # application with Mongrel during development and testing, then use it
- # also in production behind a server that's better at serving the
- # static files.
- #
- # The RailsHandler takes a mime_map parameter which is a simple suffix=mimetype
- # mapping that it should add to the list of valid mime types.
- #
- # It also supports page caching directly and will try to resolve a request
- # in the following order:
- #
- # * If the requested exact PATH_INFO exists as a file then serve it.
- # * If it exists at PATH_INFO+".html" exists then serve that.
- # * Finally, construct a Mongrel::CGIWrapper and run Dispatcher.dispatch to have Rails go.
- #
- # This means that if you are using page caching it will actually work with Mongrel
- # and you should see a decent speed boost (but not as fast as if you use a static
- # server like Apache or Litespeed).
- class RailsHandler < Mongrel::HttpHandler
- # Construct a Mongrel::CGIWrapper and dispatch.
- def process(request, response)
- return if response.socket.closed?
-
- cgi = Mongrel::CGIWrapper.new(request, response)
- cgi.handler = self
- # We don't want the output to be really final until we're out of the lock
- cgi.default_really_final = false
-
- ActionController::Dispatcher.dispatch(cgi, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, response.body)
-
- # This finalizes the output using the proper HttpResponse way
- cgi.out("text/html",true) {""}
- rescue Errno::EPIPE
- response.socket.close
- rescue Object => rails_error
- STDERR.puts "#{Time.now.httpdate}: Error dispatching #{rails_error.inspect}"
- STDERR.puts rails_error.backtrace.join("\n")
- end
- end
- end
-end