test/webrick/test_filehandler.rb: no `.encode("filesystem")` if US-ASCII

http://ci.rvm.jp/logfiles/brlog.trunk-theap-asserts.20200618-002305
```
I, [2020-06-18T00:28:11.661066 #31625]  INFO -- :   1) Failure:
I, [2020-06-18T00:28:11.661157 #31625]  INFO -- : WEBrick::TestFileHandler#test_cjk_in_path [/tmp/ruby/v3/src/trunk-theap-asserts/test/webrick/utils.rb:72]:
I, [2020-06-18T00:28:11.661216 #31625]  INFO -- : exceptions on 1 threads:
I, [2020-06-18T00:28:11.661269 #31625]  INFO -- : U+3042 from UTF-8 to US-ASCII
```
This commit is contained in:
Yusuke Endoh 2020-06-18 09:37:54 +09:00
Родитель 35a6741816
Коммит bed17974a1
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -294,8 +294,13 @@ 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".encode("filesystem").bytes.map {|b| "%%%X" % b }.join
req = Net::HTTP::Get.new("/#{ filesystem_path }.txt")
case enc = Encoding.find('filesystem')
when Encoding::US_ASCII, Encoding::ASCII_8BIT
filesystem_path = "\u3042"
else
filesystem_path = "\u3042".encode("filesystem")
end
req = Net::HTTP::Get.new("/#{ filesystem_path.bytes.map {|b| "%%%X" % b }.join }.txt")
http.request(req){|res| assert_equal("200", res.code, log.call + "\nFilesystem encoding is #{Encoding.find('filesystem')}") }
end
end