Module Ocsigen_local_files
val section : Logs.srcexception Failed_404The requested file does not exists
exception Failed_403The requested file cannot be served: does not exists, not enough permissions ...
exception NotReadableDirectoryThe file is a directory which we should not display
type resolved = | RFile of string| RDir of string
Local file corresponding to a request. The string argument represents the real file or directory to serve, eg. foo/index.html instead of foo
val resolve :
?no_check_for:string ->
request:Ocsigen_extensions.request ->
filename:string ->
unit ->
resolvedFinds filename in the filesystem, with a possible redirection if it is a directory. Takes into account the fact that filename does not exists, is a symlink or is a directory, and raises Failed_404 or Failed_403 accordingly.
- we return
"filename/index.html"iffilenamecorresponds to a directory,"filename/index.html"is valid, and"index.html"is one possible index (trying all possible indexes in order) - we raise
Failed_404iffilenamecorresponds to a directory, no index exists andlist_dir_contentis false. Warning: this behaviour is not the same as Apache's but it corresponds to a missing service in Eliom (answers 404). This also allows to have an Eliom service after a "forbidden" directory - we raise
Failed_403iffilenameis a symlink that must not be followed - raises
Failed_404iffilenamedoes not exist, or is a special file - otherwise returns
filename
no_check_for is supposed to be a prefix of filename ; directories above no_check_for are not checked for symlinks