summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/webrick/httpservlet/filehandler.rb7
-rw-r--r--test/webrick/test_filehandler.rb11
2 files changed, 2 insertions, 16 deletions
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb
index 2044d6eabe..5bd96317e6 100644
--- a/lib/webrick/httpservlet/filehandler.rb
+++ b/lib/webrick/httpservlet/filehandler.rb
@@ -36,17 +36,12 @@ module WEBrick
def initialize(server, local_path)
super(server, local_path)
- @local_path = local_path
+ @local_path = local_path.dup.force_encoding("UTF-8")
end
# :stopdoc:
def do_GET(req, res)
- case enc = Encoding.find('filesystem')
- when Encoding::US_ASCII, Encoding::ASCII_8BIT
- else
- @local_path = @local_path.dup.force_encoding(enc)
- end
st = File::stat(@local_path)
mtime = st.mtime
res['etag'] = sprintf("%x-%x-%x", st.ino, st.size, st.mtime.to_i)
diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb
index ff75f07c53..edf0d8b12c 100644
--- a/test/webrick/test_filehandler.rb
+++ b/test/webrick/test_filehandler.rb
@@ -294,16 +294,7 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase
config = { :DocumentRoot => dir }
TestWEBrick.start_httpserver(config) do |server, addr, port, log|
http = Net::HTTP.new(addr, port)
- filesystem_path = "\u3042"
- case Encoding.find('filesystem')
- when Encoding::US_ASCII, Encoding::ASCII_8BIT
- else
- begin
- filesystem_path = "\u3042".encode("filesystem")
- rescue Encoding::UndefinedConversionError
- end
- end
- req = Net::HTTP::Get.new("/#{ filesystem_path.bytes.map {|b| "%%%X" % b }.join }.txt")
+ req = Net::HTTP::Get.new("/%E3%81%82.txt")
http.request(req){|res| assert_equal("200", res.code, log.call + "\nFilesystem encoding is #{Encoding.find('filesystem')}") }
end
end