HTTPD0 API DOCUMENTATION Max Rottenkolber Friday, 16 September 2016 Table of Contents 1 httpd0 1.1 *request‑size* (Variable) 1.2 *request‑timeout* (Variable) 1.3 destroy‑httpd (Function) 1.4 make‑httpd (Function) 1.5 make‑resource‑responder (Function) 2 httpd0.responses 2.1 *protocol‑version* (Variable) 2.2 *request‑method* (Variable) 2.3 *text‑mime* (Variable) 2.4 respond‑moved‑permanently (Function) 2.5 respond‑not‑found (Function) 2.6 respond‑not‑implemented (Function) 2.7 respond‑not‑modified (Function) 2.8 respond‑ok (Macro) 2.9 uri‑encode (Function) 1 httpd0 HTTP/1.0 GET/HEAD server. Server responses are generated by functions implementing the responder function interface: — Function: resource if-modified-since Arguments and Values: resource—a pathname. if-modified-since—the value of the If-Modified-Since header represented as a universal time. Description: A responder function must produce a response to the request to resource using the helper functions provided by the httpd0.responses package. See Also: * If-Modified-Since (http://www.w3.org/Protocols/HTTP/1.0/spec.html#If-Modified-Since) * httpd0.responses 1.1 *request‑size* (Variable) Initial Value: 512 Description: Maximum request size in characters. Requests exceeding *request-size* are dropped by closing the connection. 1.2 *request‑timeout* (Variable) Initial Value: 64 Description: I/O timeout in seconds. Requests that are stalled by an I/O operation with the client for more than the specified duration are dropped by closing the connection. 1.3 destroy‑httpd (Function) Syntax: — Function: destroy‑httpd httpd Arguments and Values: httpd—an httpd0 instance as returned by make-httpd. Description: destory-httpd stops httpd and frees its resources. 1.4 make‑httpd (Function) Syntax: — Function: make‑httpd responder &key host port n‑threads socket‑backlog Arguments and Values: responder—a responder function. host—the host address to listen on as a string. The default is the wildcard address. port—a local port number. The default is 8080. n-threads—a positive integer specifying the number of threads to keep in the thread pool. Must be at least two. The default is 16. socket-backlog—a positive integer specifying the socket backlog. The default is 32. Description: make-httpd creates a httpd0 server instance with responder that listens on the specified host and port. 1.5 make‑resource‑responder (Function) Syntax: — Function: make‑resource‑responder root Arguments and Values: root—a directory pathname. Description: make-resource-responder returns a responder function that serves the files under root. 2 httpd0.responses Toolkit for writing responder functions. Includes common responses and generic response templates. 2.1 *protocol‑version* (Variable) Initial Value: NIL Description: *protocol-version* is bound to a symbol indicating the protocol version is use when calling a responder function. *protocol-version* can be either :0.9 or :1.0 to indicate HTTP/0.9 or HTTP/1.0 respectively. 2.2 *request‑method* (Variable) Initial Value: NIL Description: *request-method* is bound to a symbol indicating the request method served when calling a responder function. *request-method* can be either :get or :head indicating a GET or HEAD request respectively. 2.3 *text‑mime* (Variable) Initial Value: ("text" "plain; charset=utf-8") Description: *text-mime* is bound to a list of two strings that designates a MIME type, to which responses for the text/plain MIME type will be upgraded to. 2.4 respond‑moved‑permanently (Function) Syntax: — Function: respond‑moved‑permanently location Arguments and Values: location—a string denoting a URI. Description: respond-moved-permanently responds with HTTP status :moved-permanently to location. 2.5 respond‑not‑found (Function) Syntax: — Function: respond‑not‑found Arguments and Values: None. Description: respond-not-found responds with HTTP status :not-found. 2.6 respond‑not‑implemented (Function) Syntax: — Function: respond‑not‑implemented Arguments and Values: None. Description: respond-not-implemented responds with HTTP status :not-implemented. 2.7 respond‑not‑modified (Function) Syntax: — Function: respond‑not‑modified Arguments and Values: None. Description: respond-not-modified responds with HTTP status :not-modified. 2.8 respond‑ok (Macro) Syntax: — Macro: respond‑ok (length type write‑date) &body body Arguments and Values: length—a non-negative integer. type—a list of two strings designating a MIME type. write-date—a universal time. body—forms that print length bytes to *standard-output*. Description: respond-ok responds with HTTP status :ok for an entity of length bytes with MIME type and write-date. The body forms must write the contents of the HTTP entity to *standard-output*. 2.9 uri‑encode (Function) Syntax: — Function: uri‑encode string Arguments and Values: string—a string. Description: uri-encode returns an URI safe copy of string. Note that uri-encode will not encode reserved characters. See Also: * percent-encoding (http://tools.ietf.org/html/rfc3986#section-2.1)