I use Ruby at work, and I play with Elixir at home. So I have a perfect work-life balance, I would say.
dalgona / microscope Goto Github PK
View Code? Open in Web Editor NEWA simple static web server based on cowboy
License: MIT License
A simple static web server based on cowboy
License: MIT License
The server responds with HTTP 404 when the requested path contains %20
.
I assume this issue can be resolved with URL decoding.
Startup command:
% mix microscope -p 57570 ~/ms-test --index
Local directory listing:
% ls -Rl ~/ms-test
/home/###/ms-test:
합계 12
drwxr-xr-x 2 ### ### 4096 12월 23 14:11 directory with spaces
-rw-r--r-- 1 ### ### 14 12월 23 14:10 hello.txt
-rw-r--r-- 1 ### ### 71 12월 23 14:13 space test.txt
/home/dalgona/ms-test/directory with spaces:
합계 4
-rw-r--r-- 1 ### ### 26 12월 23 14:11 test.txt
Access log:
[404] 211.232.228.241 GET /directory%20with%20spaces
[200] 211.232.228.241 GET /
[404] 211.232.228.241 GET /space%20test.txt
[404] 211.232.228.241 GET /space%20test.txt
This error is caused by File.stat!/2
. I came up with two possible solutions:
File.stat!/2
with File.lstat!/2
to avoid dereferencing symlinks.File.stat!/2
with File.stat/2
and discard all item matching {:error, _}
.Startup command:
% mix microscope -p 57570 ~/ms-test --index
Local directory listing:
% ls -Rl
.:
합계 12
lrwxrwxrwx 1 ### ### 11 12월 23 14:34 broken-link.txt -> nonexistent
drwxr-xr-x 2 ### ### 4096 12월 23 14:11 directory with spaces
lrwxrwxrwx 1 ### ### 9 12월 23 14:32 hello-link.txt -> hello.txt
-rw-r--r-- 1 ### ### 14 12월 23 14:10 hello.txt
-rw-r--r-- 1 ### ### 71 12월 23 14:13 space test.txt
./directory with spaces:
합계 4
-rw-r--r-- 1 ### ### 26 12월 23 14:11 test.txt
Error output:
# (while processing GET /)
14:34:50.052 [error] Process #PID<0.227.0> raised an exception
** (ErlangError) erlang error: [reason: %File.Error{action: "read file stats", p
ath: "/home/dalgona/ms-test//broken-link.txt", reason: :enoent}, mfa: {Microscop
e.Handler, :handle, 2}, stacktrace: [{File, :stat!, 2, [file: 'lib/file.ex', lin
e: 289]}, {Microscope.IndexBuilder, :"-make_entries/1-fun-1-", 2, [file: 'lib/mi
croscope/index_builder.ex', line: 33]}, {Stream, :"-map/2-fun-0-", 4, [file: 'li
b/stream.ex', line: 490]}, {Enumerable.List, :reduce, 3, [file: 'lib/enum.ex', l
ine: 2843]}, {Enumerable.Stream, :do_each, 4, [file: 'lib/stream.ex', line: 1284
]}, {Enum, :reduce, 3, [file: 'lib/enum.ex', line: 1627]}, {Enum, :to_list, 1, [
file: 'lib/enum.ex', line: 2346]}, {Microscope.IndexBuilder, :build, 2, [file: '
lib/microscope/index_builder.ex', line: 13]}], req: [socket: #Port<0.5967>, tran
sport: :ranch_tcp, connection: :keepalive, pid: #PID<0.227.0>, method: "GET", ve
rsion: :"HTTP/1.1", peer: {{211, 232, 228, 241}, 12743}, host: "include.iostream
.kr", host_info: :undefined, port: 57570, path: "/", path_info: [], qs: "", qs_v
als: :undefined, bindings: [], headers: [{"host", "include.iostream.kr:57570"},
{"connection", "keep-alive"}, {"cache-control", "max-age=0"}, {"upgrade-insecure
-requests", "1"}, {"user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl
eWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"}, {"accept
", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"}
, {"accept-encoding", "gzip, deflate, sdch"}, {"accept-language", "ko-KR,ko;q=0.
8,en-US;q=0.6,en;q=0.4"}], p_headers: [{"connection", ["keep-alive"]}], cookies:
:undefined, meta: [], body_state: :waiting, buffer: "", multipart: :undefined,
resp_compress: true, resp_state: :waiting, resp_headers: [], resp_body: "", onre
sponse: :undefined], state: %{base: "", cb_mods: [Microscope.Logger], index: tru
e, src: "/home/dalgona/ms-test"}]
(cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.