diff options
author | Kazuhiro NISHIYAMA <zn@mbf.nifty.com> | 2020-06-15 10:43:01 +0900 |
---|---|---|
committer | Kazuhiro NISHIYAMA <znz@users.noreply.github.com> | 2020-06-15 11:25:33 +0900 |
commit | 93e6fa1d319d19ce7fba37e4b9924862447b9f38 (patch) | |
tree | 7093fb3e8691e1288a3b69042c982a1ecdd9be5f /lib/webrick/httpservlet | |
parent | 80bd3aa32b92f952dab4330281ff049739439568 (diff) |
Use filesystem encoding in do_GET of filehandler
Try to fix 404 error on mswinci.
https://rubyci.org/logs/mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-master/log/20200614T225859Z.fail.html.gz
```
1) Failure:
WEBrick::TestFileHandler#test_cjk_in_path [D:/tmp/mswin-build20200615-24932-11ykstf/ruby/test/webrick/utils.rb:72]:
exceptions on 2 threads:
webrick log start:
[2020-06-15 09:48:29] ERROR `/あ.txt' not found.
webrick log end.
<"200"> expected but was
<"404">.
---
<[]> expected but was
<["[2020-06-15 09:48:29] ERROR `/\xE3\x81\x82.txt' not found.\n"]>.
```
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3227
Diffstat (limited to 'lib/webrick/httpservlet')
-rw-r--r-- | lib/webrick/httpservlet/filehandler.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb index 0780faf202..2044d6eabe 100644 --- a/lib/webrick/httpservlet/filehandler.rb +++ b/lib/webrick/httpservlet/filehandler.rb @@ -42,6 +42,11 @@ module WEBrick # :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) |