- some 9base commands do not build on my system, but thankfully none of the
tools required by httpd.execline fail.
+ [toybox](http://www.landley.net/toybox/): `wc(1)`,
-`date(1p)`, `stat(1)`, `cat(1)`, `timeout(1)`
+`date(1p)`, `stat(1)`, `cat(1)`, `timeout(1)`, `cksum(1)` (optional; used to
+generate ETags)
- toybox’s `tr(1)` is pending but seems to work
+ [busybox](https://www.busybox.net/): `gzip(1)` (optional; required for gzip
encoding)
+ `httpd_execline_default_index`: the file to default to if a resource matches
a directory. defaults to `index.html`
+ `HTTPD_EXECLINE_GZIP`: if set, use `gzip(1)` to compress found resources.
++ `HTTPD_EXECLINE_GENERATE_ETAGS`: if set, use `cksum(1)` to generate `ETag`s
+ for all resources on the fly
++ `HTTPD_EXECLINE_MAX_AGE`: if `HTTPD_EXECLINE_CACHE` is set, this variable
+ controls the max-age directive. defaults to `604800`
\ No newline at end of file
s6-echo -n -- identity
}
+ backtick -D "no-cache" Cache-Control {
+ if { eltest -v HTTPD_EXECLINE_GENERATE_ETAGS }
+ importas -D "604800" -u HTTPD_EXECLINE_MAX_AGE HTTPD_EXECLINE_MAX_AGE
+ s6-echo -n -- ${HTTPD_EXECLINE_MAX_AGE}
+ }
+
+ backtick -D "" optional_etag_line {
+ if { eltest -v HTTPD_EXECLINE_GENERATE_ETAGS }
+ backtick -i -E -n cksum {
+ redirfd -r 0 supported_domains/${resource}
+ cksum
+ }
+ case -N -- ${cksum} {
+ "^([^ ]+) .*$" {
+ importas -i -u actual_cksum 1
+ s6-echo -n -- "Etag: "${actual_cksum}"\r\n"
+ }
+ }
+ s6-echo -n -- ''
+ }
+
##### 4.1. determine found resource's Content-Type ###
backtick -i -n Content-Type {
define Content_Type_override_file configuration/overrides/${resource}/Content-Type
multisubstitute {
importas -i -u output_executable output_executable
importas -i -u status_code_and_message status_code_and_message
+ importas -i -u Cache-Control Cache-Control
importas -i -u Content-Encoding Content-Encoding
importas -i -u Content-Length Content-Length
importas -i -u Content-Type Content-Type
+ importas -i -u optional_etag_line optional_etag_line
importas -i -u Date Date
importas -i -u Last-Modified Last-Modified
importas -i -u extra_headers extra_headers
}
+ if { log.execline line is ${optional_etag_line} }
if {
s6-echo -n -- "HTTP/1.1 "${status_code_and_message}"\r
Content-Encoding: "${Content-Encoding}"\r
Content-Type: "${Content-Type}"\r
Content-Length: "${Content-Length}"\r
-Last-Modified: "${Last-Modified}"\r
+Cache-Control: "${Cache-Control}"\r
+"${optional_etag_line}"\r\nLast-Modified: "${Last-Modified}"\r
Date: "${Date}${extra_headers}"
\r
"