sendfile(1)


Table of Contents

1. NAME
2. SYNOPSIS
3. DESCRIPTION
4. OPTIONS
5. AUTHOR
6. SEE ALSO

1. NAME

sendfile - Static file handler for ashd(7)

2. SYNOPSIS

sendfile [-c CONTENT-TYPE] [-f FILE] METHOD URL REST

3. DESCRIPTION

sendfile serves static files by sending them exactly as they are to clients. It needs to be called with the X-Ash-File header added to the request, as dirplex(1) does, unless the -f option is given.

sendfile is a transient handler, as defined in ashd(7), and the METHOD, URL and REST arguments will normally be added by the parent handler.

Normally, sendfile will serve the file named by the X-Ash-File header, and fail with a 404 error in case the rest string is not empty. However, if the -f argument is given, the given FILE will always be served instead, and the X-Ash-File header and any rest string is ignored.

A file’s MIME type may be specified explicitly either by using the -c option, or by passing the header X-Ash-Content-Type to sendfile with the MIME type of the file. That header might, for instance, be set using the set directives of dirplex(1) or patplex(1).

If a MIME-type is not explicitly specified, sendfile uses libmagic(3) to determine the MIME-type automatically. If sendfile is compiled with support for filesystem attributes (see attr(5) if your system has support for such attributes), the attributes user.ash-mime-type, user.mime-type, user.mime_type or user.Content-Type will be checked, in that order, and if one is present on the file in question, its value will be used instead of using libmagic.

sendfile supports the following HTTP features:

  • Caching, using the Last-Modified and related headers.
  • Partial content, using the Range and related headers.

4. OPTIONS

-c CONTENT-TYPE
Send CONTENT-TYPE as the file’s MIME-type instead of trying to auto-detect the file type.
-f FILE
Ignore the X-Ash-File header and force FILE to be served instead. Any remaining rest string is also ignored.

5. AUTHOR

Fredrik Tolf <fredrik@dolda2000.com>

6. SEE ALSO

dirplex(1), psendfile(1), ashd(7)