I was trying to open a small and simple http server to share some files on LAN (or online on public IP). On a bit of research i found python -m SimpleHTTPServer does the job but it has horrible concurrent request issues. Users tell me that when they're downloading a file (typically large file, like movies), the browsing becomes extremely slow.
Being a rails programmer myself, i found this:
s=WEBrick::HTTPServer.new({DocumentRoot: ".", Port: 8000 })
trap("INT"){s.shutdown}
s.start
This was perfect with regards to being simple and didn't have problems like python's. However there's one thing that has me baffled. When filenames on my Ubuntu has characters that aren't ascii encoded it throws error: invalid byte sequence in US-ASCII.
My search into the webrick gem revealed it assumes a US-ASCII encoding. I wonder why not UTF-8. I tried stuff including:
At the start of my ruby file:
Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8
in ubuntu environment:
export LANGUAGE=en_US.UTF-8 export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8
Iconv conversions
and God knows what else in the 4 hours i've been on it.
I really don't understand how I can tell webrick to use utf-8 character encoding for its server.