aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/CHANGELOG4
-rw-r--r--railties/bin/server16
-rw-r--r--railties/lib/webrick_server.rb10
3 files changed, 20 insertions, 10 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 81de077c39..06183484a4 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,8 +1,10 @@
*SVN*
+* Added -m/--mime-types option to the WEBrick server, so you can specify a Apache-style mime.types file to load #2059 [ask@develooper.com]
+
* Added -c/--svn option to the generator that'll add new files and remove destroyed files using svn add/revert/remove as appropriate #2064 [kevin.clark@gmail.com]
-* Added -c/--charset option to WEBrick controller, so you can specify a default charset (which without changes is UTF-8) #2084 [wejn@box.cz]
+* Added -c/--charset option to WEBrick server, so you can specify a default charset (which without changes is UTF-8) #2084 [wejn@box.cz]
* Make the default stats task extendable by modifying the STATS_DIRECTORIES constant
diff --git a/railties/bin/server b/railties/bin/server
index 3a8cc68258..38f35c4285 100644
--- a/railties/bin/server
+++ b/railties/bin/server
@@ -4,12 +4,12 @@ require 'webrick'
require 'optparse'
OPTIONS = {
- :port => 3000,
- :ip => "0.0.0.0",
- :environment => "development",
- :server_root => File.expand_path(File.dirname(__FILE__) + "/../public/"),
- :server_type => WEBrick::SimpleServer,
- :charset => "UTF-8"
+ :port => 3000,
+ :ip => "0.0.0.0",
+ :environment => "development",
+ :server_root => File.expand_path(File.dirname(__FILE__) + "/../public/"),
+ :server_type => WEBrick::SimpleServer,
+ :charset => "UTF-8"
}
ARGV.options do |opts|
@@ -27,6 +27,10 @@ ARGV.options do |opts|
opts.on("-e", "--environment=name", String,
"Specifies the environment to run this server under (test/development/production).",
"Default: development") { |OPTIONS[:environment]| }
+ opts.on("-m", "--mime-types=filename", String,
+ "Specifies an Apache style mime.types configuration file to be used for mime types",
+ "Default: none") { |mime_types_file| OPTIONS[:mime_types] = WEBrick::HTTPUtils::load_mime_types(mime_types_file) }
+
opts.on("-d", "--daemon",
"Make Rails run as a Daemon (only works if fork is available -- meaning on *nix)."
) { OPTIONS[:server_type] = WEBrick::Daemon }
diff --git a/railties/lib/webrick_server.rb b/railties/lib/webrick_server.rb
index 4a73872ba3..f3938b7419 100644
--- a/railties/lib/webrick_server.rb
+++ b/railties/lib/webrick_server.rb
@@ -46,7 +46,11 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
def self.dispatch(options = {})
Socket.do_not_reverse_lookup = true # patch for OS X
- server = WEBrick::HTTPServer.new(:Port => options[:port].to_i, :ServerType => options[:server_type], :BindAddress => options[:ip])
+ server = WEBrick::HTTPServer.new(:Port => options[:port].to_i,
+ :ServerType => options[:server_type],
+ :BindAddress => options[:ip],
+ :MimeTypes => options[:mime_types]
+ )
server.mount('/', DispatchServlet, options)
trap("INT") { server.shutdown }
@@ -89,8 +93,8 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
path.gsub!('+', ' ') # Unescape + since FileHandler doesn't do so.
req.instance_variable_set(:@path_info, path) # Set the modified path...
-
- @file_handler.send(:service, req, res)
+
+ @file_handler.send(:service, req, res)
return true
rescue HTTPStatus::PartialContent, HTTPStatus::NotModified => err
res.set_error(err)