[minor updates to the directory serving section Jeremy Shaw **20101115180236 Ignore-this: 27591e53155378d854d1ebd9cf0fad3f ] hunk ./FileServingDirectory.lhs 37 -

The formula for mapping the URL to a file on disk is simply:

+

The formula for mapping the URL to a file on disk is just what you would expect:

hunk ./FileServingDirectory.lhs 43 -

Note that we are only mapping the unconsumed portion of the URL. For example, let says that we had the handler:

+

So if the handler is:

hunk ./FileServingDirectory.lhs 47 -> dir "static" $ serveDirectory EnableBrowsing ["index.html"] "/srv/mysite/datafiles" + dir "static" $ serveDirectory EnableBrowsing ["index.html"] "/srv/mysite/datafiles" hunk ./FileServingDirectory.lhs 51 -

And the requested url is:

+

And the request URL is:

hunk ./FileServingDirectory.lhs 54 -http://localhost/static/foo/bar.html +http://localhost/static/foo/bar.html hunk ./FileServingDirectory.lhs 57 -

Because, dir "static" consumes the static component we are going to have:

+

Then we are going to look for:

hunk ./FileServingDirectory.lhs 60 -/srv/mysite/datafiles </> foo/bar.html => /srv/mysite/datafiles/foo/bar.html +/srv/mysite/datafiles </> foo/bar.html => /srv/mysite/datafiles/foo/bar.html hunk ./FileServingDirectory.lhs 79 +

File Serving Security

+ +

The request URL is sanitized so that users can not escape the top-level directory by adding extra .. or / characters to the URL.

+ +

The file serving code will follow symlinks. If you do not want that behavior then you will need to roll your own serving function. See the section on Advanced File Serving for more information.