commit 6b0071b6f95890b2a85ae1a3352b5256f8e9c911 Author: Max Rottenkolber Date: Fri Sep 16 14:43:59 2016 +0200 Documentation updates. diff --git a/software/httpd0/api.mk2 b/software/httpd0/api.mk2 index f40d948..6f1db91 100644 --- a/software/httpd0/api.mk2 +++ b/software/httpd0/api.mk2 @@ -24,7 +24,7 @@ + httpd0.responses - < \*request-size\* \(Variable\) + < \*request‑size\* \(Variable\) *Initial Value:* @@ -32,13 +32,13 @@ *Description:* - Maximum size of a request in bytes. Requests exceeding + Maximum request size in characters. Requests exceeding {\*request-size\*} are dropped by closing the connection. > - < \*request-timeout\* \(Variable\) + < \*request‑timeout\* \(Variable\) *Initial Value:* @@ -46,18 +46,18 @@ *Description:* - Timeout for clients to submit request in seconds. Requests that can not - be received within the specified amount of time are dropped by closing - the connection. + 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. > - < destroy-httpd \(Function\) + < destroy‑httpd \(Function\) *Syntax:* - — Function: *destroy-httpd* _httpd_ + — Function: *destroy‑httpd* _httpd_ *Arguments and Values:* @@ -70,45 +70,41 @@ > - < make-httpd \(Function\) + < make‑httpd \(Function\) *Syntax:* - — Function: *make-httpd* _responder_ {&key} _host_ _port_ _n-threads_ - _socket-backlog_ + — Function: *make‑httpd* _responder_ {&key} _host_ _port_ _n‑threads_ + _socket‑backlog_ *Arguments and Values:* _responder_—a _responder function_. - _host_—a _host_ as defined by usocket. The default is - {usocket:\*wildcard-host\*}. + _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 - kept by usocket. The default is 32. + _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_. - *See Also:* - - + [usocket](https://common-lisp.net/project/usocket/) - > - < make-resource-responder \(Function\) + < make‑resource‑responder \(Function\) *Syntax:* - — Function: *make-resource-responder* _root_ + — Function: *make‑resource‑responder* _root_ *Arguments and Values:* @@ -130,7 +126,7 @@ generic response templates. - < \*protocol-version\* \(Variable\) + < \*protocol‑version\* \(Variable\) *Initial Value:* @@ -146,7 +142,7 @@ > - < \*request-method\* \(Variable\) + < \*request‑method\* \(Variable\) *Initial Value:* @@ -162,7 +158,7 @@ > - < \*text-mime\* \(Variable\) + < \*text‑mime\* \(Variable\) *Initial Value:* @@ -177,11 +173,11 @@ > - < respond-moved-permanently \(Function\) + < respond‑moved‑permanently \(Function\) *Syntax:* - — Function: *respond-moved-permanently* _location_ + — Function: *respond‑moved‑permanently* _location_ *Arguments and Values:* @@ -195,11 +191,11 @@ > - < respond-not-found \(Function\) + < respond‑not‑found \(Function\) *Syntax:* - — Function: *respond-not-found* _\_ + — Function: *respond‑not‑found* _\_ *Arguments and Values:* @@ -212,11 +208,11 @@ > - < respond-not-implemented \(Function\) + < respond‑not‑implemented \(Function\) *Syntax:* - — Function: *respond-not-implemented* _\_ + — Function: *respond‑not‑implemented* _\_ *Arguments and Values:* @@ -229,11 +225,11 @@ > - < respond-not-modified \(Function\) + < respond‑not‑modified \(Function\) *Syntax:* - — Function: *respond-not-modified* _\_ + — Function: *respond‑not‑modified* _\_ *Arguments and Values:* @@ -246,11 +242,11 @@ > - < respond-ok \(Macro\) + < respond‑ok \(Macro\) *Syntax:* - — Macro: *respond-ok* {\(}_length_ _type_ _write-date_{\)} {&body} + — Macro: *respond‑ok* {\(}_length_ _type_ _write‑date_{\)} {&body} _body_ *Arguments and Values:* @@ -272,11 +268,11 @@ > - < uri-encode \(Function\) + < uri‑encode \(Function\) *Syntax:* - — Function: *uri-encode* _string_ + — Function: *uri‑encode* _string_ *Arguments and Values:* commit e535db6dd1376feeba1a51f3ae7683b9e3f448e6 Author: Max Rottenkolber Date: Sun Jul 26 20:43:48 2015 +0200 Add httpd0 documentation. diff --git a/software/httpd0/api.mk2 b/software/httpd0/api.mk2 new file mode 100644 index 0000000..f40d948 --- /dev/null +++ b/software/httpd0/api.mk2 @@ -0,0 +1,297 @@ +< 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 + + + < \*request-size\* \(Variable\) + + *Initial Value:* + + {512} + + *Description:* + + Maximum size of a request in bytes. Requests exceeding + {\*request-size\*} are dropped by closing the connection. + + > + + + < \*request-timeout\* \(Variable\) + + *Initial Value:* + + {64} + + *Description:* + + Timeout for clients to submit request in seconds. Requests that can not + be received within the specified amount of time are dropped by closing + the connection. + + > + + + < 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. + + > + + + < make-httpd \(Function\) + + *Syntax:* + + — Function: *make-httpd* _responder_ {&key} _host_ _port_ _n-threads_ + _socket-backlog_ + + *Arguments and Values:* + + _responder_—a _responder function_. + + _host_—a _host_ as defined by usocket. The default is + {usocket:\*wildcard-host\*}. + + _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 + kept by usocket. The default is 32. + + *Description:* + + {make-httpd} creates a httpd0 server instance with _responder_ that + listens on the specified _host_ and _port_. + + *See Also:* + + + [usocket](https://common-lisp.net/project/usocket/) + + > + + + < 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_. + + > + +> + + +< httpd0.responses + + Toolkit for writing _responder functions_. Includes common responses and + generic response templates. + + + < \*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. + + > + + + < \*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. + + > + + + < \*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. + + > + + + < 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_. + + > + + + < respond-not-found \(Function\) + + *Syntax:* + + — Function: *respond-not-found* _\_ + + *Arguments and Values:* + + None. + + *Description:* + + {respond-not-found} responds with HTTP status {:not-found}. + + > + + + < respond-not-implemented \(Function\) + + *Syntax:* + + — Function: *respond-not-implemented* _\_ + + *Arguments and Values:* + + None. + + *Description:* + + {respond-not-implemented} responds with HTTP status {:not-implemented}. + + > + + + < respond-not-modified \(Function\) + + *Syntax:* + + — Function: *respond-not-modified* _\_ + + *Arguments and Values:* + + None. + + *Description:* + + {respond-not-modified} responds with HTTP status {:not-modified}. + + > + + + < 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\*}. + + > + + + < 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) + + > + +> +