+ [toybox](http://www.landley.net/toybox/): `wc(1)`,
`date(1p)`, `stat(1)`, `cat(1)`, `timeout(1)`
- toybox’s `tr(1)` is pending but seems to work
++ [busybox](https://www.busybox.net/): `gzip(1)` (optional; required for gzip
+ encoding)
+ etc.: presumably, your system already has `chroot(1)`
note that if you build execline and s6-portable-utils with slashpackage
+ the file
`./visible-to-httpd/configuration/overrides/httpd-execline.eerie.garden/index.xhtml/headers/Location`
containing `https://github.com/single-right-quote/httpd.execline`
+
+### environment variables
+
++ `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.
tr A-Z a-z
}
+ #### special case: content-encoding header
+ #
+ # test that the client accepts a gzip-encoded body, setting the
+ # variable HTTPD_EXECLINE_CLIENT_WANTS_GZIP if they do
+ ifelse {
+ eltest -v HTTPD_EXECLINE_GZIP
+ -a ${header_name} = accept-encoding
+ }
+ {
+ backtick -x HTTPD_EXECLINE_CLIENT_WANTS_GZIP {
+ backtick -E -i -n header_contents_lowercase {
+ pipeline { s6-echo -n -- ${header_contents} }
+ tr A-Z a-z
+ }
+ # TODO: is there a single regexp fur this?
+ eltest ${header_contents_lowercase} =~ "[, \t](x-)?gzip[, \t]"
+ -o ${header_contents_lowercase} =~ "[, \t](x-)?gzip$"
+ -o ${header_contents_lowercase} =~ "^(x-)?gzip[, \t]"
+ -o ${header_contents_lowercase} =~ "^(x-)?gzip$"
+ }
+ ${0}
+ ${supported_hostname_test}
+ ${@}
+ }
+
#### special case: host header
#
# short circuits the program
}
#### 4. send response ###
+ backtick -i output_executable {
+ ifelse {
+ eltest -v HTTPD_EXECLINE_GZIP
+ -a -v HTTPD_EXECLINE_CLIENT_WANTS_GZIP
+ }
+ {
+ if { log.execline "info: client wants gzip" }
+ s6-echo -n -- gzip
+ }
+ s6-echo -n -- cat
+ }
+
+ backtick -i -n Content-Encoding {
+ ifelse {
+ eltest -v HTTPD_EXECLINE_GZIP
+ -a -v HTTPD_EXECLINE_CLIENT_WANTS_GZIP
+ }
+ {
+ s6-echo -n -- gzip
+ }
+ s6-echo -n -- identity
+ }
+
##### 4.1. determine found resource's Content-Type ###
backtick -i -n Content-Type {
define Content_Type_override_file configuration/overrides/${resource}/Content-Type
##### 4.3. send the response ###
multisubstitute {
+ importas -i -u output_executable output_executable
importas -i -u status_code_and_message status_code_and_message
+ importas -i -u Content-Encoding Content-Encoding
importas -i -u Content-Length Content-Length
importas -i -u Content-Type Content-Type
importas -i -u Date Date
}
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
}
foreground {
if -t { eltest \${method} = GET }
- cat supported_domains/${resource}
+ redirfd -r 0 supported_domains/${resource}
+ ${output_executable}
}
# hack: write(3p) does not guarantee that all the
# content actually gets written before this process