1 Running the Web Server
2 Scheme Servlets
3 Web Language Servlets
4 Configuration
5 Dispatchers
6 Web Config Unit
7 Web Server Unit
8 Continuation Managers
9 Internal
10 Troubleshooting
11 Acknowledgements
Index
On this page:
make
Version: 4.0.2

 

5.11 Serving Files

 (require web-server/dispatchers/dispatch-files)

The web-server/dispatchers/dispatch-files module allows files to be served. It defines a dispatcher construction procedure.

(make

 

#:url->path url->path

 

 

 

 

 

 [

#:path->mime-type path->mime-type

 

 

 

 

 

 

#:indices indices])

 

 

dispatcher?

  url->path : url->path?

  

path->mime-type

 

:

 

(path? . -> . bytes?)

 

 

 

=

 

(lambda (path) TEXT/HTML-MIME-TYPE)

  indices : (listof string?) = (list "index.html" "index.htm")

Uses url->path to extract a path from the URL in the request object. If this path does not exist, then the dispatcher does not apply and next-dispatcher is invoked. If the path is a directory, then the indices are checked in order for an index file to serve. In that case, or in the case of a path that is a file already, path->mime-type is consulted for the MIME Type of the path. The file is then streamed out the connection object.

This dispatcher supports HTTP Range GET requests and HEAD requests.