diff options
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/webrick_server.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/railties/lib/webrick_server.rb b/railties/lib/webrick_server.rb index 5814f87a06..22cdc9a845 100644 --- a/railties/lib/webrick_server.rb +++ b/railties/lib/webrick_server.rb @@ -6,6 +6,7 @@ require 'stringio' include WEBrick + class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet REQUEST_MUTEX = Mutex.new @@ -42,16 +43,28 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet def handle_file(req, res) begin + add_dot_html(req) @file_handler.send(:do_GET, req, res) + remove_dot_html(req) return true rescue HTTPStatus::PartialContent, HTTPStatus::NotModified => err res.set_error(err) return true rescue => err return false + ensure + remove_dot_html(req) end end + def add_dot_html(req) + if /^([^.]+)$/ =~ req.path then req.instance_variable_set(:@path_info, "#{$1}.html") end + end + + def remove_dot_html(req) + if /^([^.]+).html$/ =~ req.path then req.instance_variable_set(:@path_info, $1) end + end + def handle_dispatch(req, res, origin = nil) env = req.meta_vars.clone env["QUERY_STRING"] = req.request_uri.query |