mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
better logging, do not error on close
This commit is contained in:
parent
20a36919ce
commit
0d1bccfd1b
1 changed files with 7 additions and 3 deletions
|
|
@ -95,7 +95,7 @@ let vfs_of_dir (top : string) : vfs =
|
|||
|
||||
let read_file_content f =
|
||||
let ic = Unix.(openfile (top // f) [ O_RDONLY ] 0) in
|
||||
Tiny_httpd_stream.of_fd ic
|
||||
Tiny_httpd_stream.of_fd_close_noerr ic
|
||||
|
||||
let create f =
|
||||
let oc = open_out_bin (top // f) in
|
||||
|
|
@ -330,8 +330,12 @@ let add_vfs_ ~on_fs ~top ~config ~vfs:((module VFS : VFS) as vfs) ~prefix server
|
|||
~headers:(mime_type @ [ "Etag", Lazy.force mtime ])
|
||||
~code:200 stream
|
||||
with e ->
|
||||
S.Response.fail ~code:500 "error while reading file: %s"
|
||||
(Printexc.to_string e)
|
||||
let bt = Printexc.get_raw_backtrace () in
|
||||
let msg = Printexc.to_string e in
|
||||
Log.error (fun k ->
|
||||
k "dir.get failed: %s@.%s" msg
|
||||
(Printexc.raw_backtrace_to_string bt));
|
||||
S.Response.fail ~code:500 "error while reading file: %s" msg
|
||||
))
|
||||
else
|
||||
S.add_route_handler server ~meth:`GET (route ()) (fun _ _ ->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue