CL-HTTP Appendix C: Export Type Reference


Reference Manual | Prev: Appendix B. Condition Hierarchy | Next: Appendix D. HTML Macro Reference


This appendix documents all URL export types supported by http:export-url. The export type is the second argument to export-url and determines how the server handles requests for the URL. Additional keyword arguments configure the export behavior.

All export types accept these common keyword arguments:

Static File Export Types

Static file export types serve files from the local filesystem. The server determines the content type from the export type and serves the file with appropriate headers. For these types, either export-url is called with a directory hierarchy (see Directory Exports) or the URL's pathname is set via :pathname.

Export TypeContent TypeDescription
:html-file text/html; charset=utf-8 HTML document. Alternate extensions: .htm.
:text-file text/plain; charset=utf-8 Plain text file. Alternate extensions: .txt, .lisp, .c, .h, .sh, .script, .bib.
:lisp-file text/plain; charset=utf-8 Lisp source file. Alternate extensions: .lsp, .cl, .asd.
:xml-file text/xml XML document. Alternate extensions: .rdf, .daml, .opml.
:css-file text/css Cascading Style Sheet.
:java-script-file text/javascript JavaScript file. Alternate extensions: .js.
:json-data application/json JSON data file.
:gif-image image/gif GIF image (binary).
:jpeg-image image/jpeg JPEG image (binary). Alternate extensions: .jpe, .jpg.
:png-image image/png PNG image (binary).
:tiff-image image/tiff TIFF image (binary). Alternate extensions: .tif.
:ico-image image/x-icon Icon image (binary).
:x-bitmap-image image/x-xbitmap X Bitmap image.
:pict-image image/pict PICT image (binary). Alternate extensions: .pic.
:basic-audio audio/basic Basic audio (binary). Alternate extensions: .snd.
:aiff-audio audio/aiff AIFF audio (binary). Alternate extensions: .aif.
:wav-audio audio/wav WAV audio (binary).
:midi-audio audio/midi MIDI audio (binary). Alternate extensions: .mid, .kar, .rmi.
:mpeg-audio audio/mpeg MPEG audio (binary). Alternate extensions: .mp2, .mp2a, .m2a.
:mpeg3-audio audio/mpeg3 MP3 audio (binary). Alternate extensions: .mp3, .m3a.
:mp4-audio audio/mp4 MP4 audio (binary).
:aac-audio audio/mp4a-latm AAC audio (binary). Alternate extensions: .m4a, .m4b, .m4p.
:pdf-file application/pdf PDF document (binary).
:postscript-file application/postscript PostScript file. Alternate extensions: .eps, .epsf.
:compressed-file application/x-compressed Compressed archive (binary). Alternate extensions: .z, .gz, .tgz.
:binary-file application/octet-stream Binary file. Alternate extensions: .bin, .exe.
:word-file application/msword Microsoft Word (binary). Alternate extensions: .doc, .docx.
:excel-file application/excel Microsoft Excel (binary). Alternate extensions: .xls, .xlsx.
:power-point-file application/msppt Microsoft PowerPoint (binary). Alternate extensions: .pot, .pptx.
:rtf-file text/richtext Rich Text Format.
:mark-down-file text/markdown Markdown file. Served as raw Markdown text.
:avi-video video/avi AVI video (binary).
:mpeg-video video/mpeg MPEG video (binary). Alternate extensions: .mpe, .mpg, .m1v, .m2v.
:quicktime-video video/quicktime QuickTime video (binary). Alternate extensions: .mov, .moov.
:mp4-video video/mp4 MP4 video (binary).

Dynamic (Computed) Export Types

Dynamic export types serve content computed at request time by Lisp functions.

Export TypeDescriptionKey Parameters
:computed Compute a response to the HTTP GET method. The response function receives two arguments: the URL and the output stream. Can return any content type. :response-function (required) — A function of (url stream).
:header-function (optional) — A function to compute custom headers.
:pathname (optional) — An associated pathname.
:character-set (optional) — Character set for the response.
:html-computed Synonym for :computed. Older name retained for backward compatibility. Same as :computed.

Search Export Types

Export TypeDescriptionKey Parameters
:search Compute a response based on search arguments passed in the URL query string after "?". The response function uses url:search-keys to access the parsed arguments. :response-function (required) — A function of (url stream).
:header-function (optional) — Custom header function.
:search-parser (optional) — Custom parser for the search suffix.
:search-writer (optional) — Custom writer for search arguments.
:search-database (optional) — An associated search database.
:character-set (optional) — Character set.
:image-map An image map that dispatches to other URLs based on click coordinates. Subtype of searchable URL. :pathname (required) — The image file.
:map-pathname (required) — The map definition file.
:map-format (required) — The map format (e.g., :ncsa, :cern).
:export-type (required) — The image export type.

Form Export Types

Export TypeDescriptionKey Parameters
:html-form Handle HTTP POST responses from a form. The response function receives three arguments: the URL, the output stream, and a query-alist of posted values. The form HTML itself is served from a static file specified by :pathname. :response-function (required) — A function of (url stream query-alist).
:pathname (required) — The HTML file containing the form.
:header-function (optional) — Custom header function.
:server (optional) — A server object.
:character-set (optional) — Character set.
:durable-form-values (optional) — When true, form values persist across requests.
:maximum-upload-file-size (optional) — Maximum file upload size in bytes.
:html-computed-form Compute both the form (on GET) and its response (on POST). The form function generates the HTML form dynamically; the response function handles the submitted data. :form-function (required) — A function of (url stream) that generates the form.
:response-function (required) — A function of (url stream query-alist).
:header-function (optional) — Custom header function.
:character-set (optional) — Character set.
:durable-form-values (optional) — Persist form values.
:maximum-upload-file-size (optional) — Maximum upload size.
:computed-form Synonym for :html-computed-form. Newer name. Same as :html-computed-form.
:html-dynamic-form Serve a Dynamic Forms form object: GET renders the form page from its definition; POST accepts the values through W3P presentation types with automatic retry and runs the form's response function. Normally exported via http:export-dynamic-form, which computes the URL from the command-interface and form names; define-form's :export option calls it at definition time. The standard export arguments apply. Requires the DYNAMIC-FORMS system; see Chapter 13. :form (required) — The Dynamic Forms form object.
:recache-p (optional) — Recompute the form's cached HTML slots.
:recompute-url-p (optional) — Recompute the form's URL.

Redirect Export Types

Export TypeDescriptionKey Parameters
:redirect Permanently redirect requests to another URL (301 Moved Permanently). Clients and proxies may cache the redirection. :alternate-urls (required) — A list of destination URLs to redirect to.
:temporary-redirect Temporarily redirect requests to another URL (307 Temporary Redirect). Clients should not cache the redirection and must use the same HTTP method for the redirected request. :alternate-urls (required) — A list of destination URLs.

Directory Export Types

Export TypeDescriptionKey Parameters
:directory-hierarchy Export an entire directory tree. Files within the hierarchy are automatically mapped to export types based on their extensions (e.g., .html becomes :html-file, .gif becomes :gif-image). Subdirectories are exported recursively. :pathname (required) — The root directory pathname.
:recursive-p (optional) — Export subdirectories recursively (default true).
:immediate-export (optional) — Export all files immediately instead of on demand.

Standard directory export types are automatically defined for all registered file types. The macro define-standard-directory-export-types creates directory export methods for these data type categories: :html, :text, :lisp, :image, :audio, :video, :application, :world.

Server-Parsed HTML Export Types

Export TypeDescriptionKey Parameters
:shtml-file Server-parsed HTML. The file is served as HTML but server-side include directives within the document are processed before transmission. Alternate extensions: .stm. :pathname (required) — The SHTML file to serve.

Script Export Types

Export TypeDescriptionKey Parameters
:script Execute a script object in response to a request. The script determines what content to return. :script (required) — The script object to execute.
:header-function (optional) — Custom header function.

Special Export Types

Export TypeDescriptionKey Parameters
:markdown-html-file Markdown file rendered as HTML. The server converts the Markdown source to HTML before transmission. This is the default for .md files in directory exports; use set-markdown-export-type to change to :text rendering. :pathname (required) — The Markdown file.
:websocket An RFC 6455 WebSocket endpoint. The handshake is dispatched by URL like any other GET, so the endpoint inherits virtual-host context, authentication, access control and logging; the response function then runs the session rather than writing a document. A GET without the upgrade header fields is answered 426 Upgrade Required. One export serves both transports: the HTTP/1.1 upgrade and RFC 8441's Extended CONNECT over HTTP/2, which arrives as the GET it is defined to be equivalent to. See Chapter 6. :response-function (required) — A function of one argument, the connection.
:subprotocols (optional) — Subprotocol names this endpoint will speak, preferred first.
:timeout (optional) — Idle seconds; defaults to *websocket-idle-timeout*.
:max-message-size (optional) — Largest message accepted, across all frames.
:max-frame-size (optional) — Largest single frame payload accepted.
:send-frame-size (optional) — Largest payload put in one outbound frame.
:ping-interval (optional) — Seconds of silence before a keepalive PING.
:pong-timeout (optional) — Seconds to wait for the PONG.

Complete File Type List

For reference, the following file extension mappings are defined by define-url-export-types in http:server;server.lisp:

Export TypeExtensionMIME TypeCopy Mode
:html-file.htmltext/htmltext
:shtml-file.shtmltext/htmltext
:text-file.texttext/plaintext
:lisp-file.lisptext/plaintext
:sgml-file.sgmltext/sgmltext
:xml-file.xmltext/xmltext
:rss-file.rsstext/xmltext
:mark-down-file.mdtext/markdowntext
:css-file.csstext/csstext
:gif-image.gifimage/gifbinary
:png-image.pngimage/pngbinary
:x-bitmap-image.xbmimage/x-xbitmaptext
:jpeg-image.jpegimage/jpegbinary
:pict-image.pictimage/pictbinary
:tiff-image.tiffimage/tiffbinary
:ico-image.icoimage/x-iconbinary
:basic-audio.auaudio/basicbinary
:aiff-audio.aiffaudio/aiffbinary
:wav-audio.wavaudio/wavbinary
:midi-audio.midiaudio/midibinary
:mpeg-audio.mpgaaudio/mpegbinary
:mpeg3-audio.mpeg3audio/mpeg3binary
:mp4-audio.mp4aaudio/mp4binary
:aac-audio.m4aaudio/mp4a-latmbinary
:avi-video.avivideo/avibinary
:mpeg-video.mpegvideo/mpegbinary
:quicktime-video.qtvideo/quicktimebinary
:mp4-video.mp4video/mp4binary
:pdf-file.pdfapplication/pdfbinary
:postscript-file.psapplication/postscripttext
:compressed-file.zipapplication/x-compressedbinary
:binary-file.octetapplication/octet-streambinary
:rtf-file.rtftext/richtexttext
:word-file.wordapplication/mswordbinary
:power-point-file.pptapplication/mspptbinary
:excel-file.xlapplication/excelbinary
:java-script-file.javascripttext/javascripttext
:json-data.jsonapplication/jsontext
:vrml-world.vrmlx-world/x-vrmltext
:kml-file.kmlapplication/vnd.google-earth.kml+xmltext
:kmz-file.kmzapplication/vnd.google-earth.kmzbinary
:tsv-file.tsvtext/tab-separated-valuestext
:x509-file.x509application/x-x509-user-certbinary