`index.text=x:market` will always be served with a `Content-Type` of
`text/x.market`.
2. using the per-resource `overrides` folder (see below) to specify a
-`Content-Type` header explicitly.
+`Content-Type` header explicitly (but not in the `headers` subdirectory).
#### `./visible-to-httpd/configuration/default_headers/` ###
with a resource, and attach a status code other than 200 with them. a
folder named after the specific resource (including a prepended
hostname) should may contain a `status_code` file containing a
-numerical status code and optional textual message, as well as a
+numerical status code and optional textual message, a
`headers` folder, which specifies headers using the `default_headers`
-scheme.
+scheme, and a `Content-Type` file, to override any other mechanism for
+determining the Content-Type to send to the client.
+
+Note that a `Content-Type` file in the `headers` folder is always
+ignored.
a former official website for `httpd-execline.eerie.garden`
used to redirect to this github repository, thanks to
# instances of ${hostname} and ${resource} are substituted with the provided
# host and resource from the request
#
+# the script will refuse to override the Content-Type header
+#
# execs into self in order to retain an environment variable which marks
# whether a certain header has been overridden or not
sed "s@.*/([^/]*)@\\1@"
}
+ifelse {
+ pipeline { s6-echo -n -- \${header_name} }
+ grep -s -i '^[ ]*Content-Type[ ]*$' # paranoid whitespace matching
+}
+{
+ foreground { log.execline "refusing to override Content-Type header" }
+ http-print-header-directories.execline ${@}
+}
+
# short circuit on overridden header
ifelse { s6-test -v http_print_header_directories_${header_name} }
{
#### 4. send response ###
##### 4.1. determine found resource's Content-Type ###
- #
backtick -i -n Content-Type {
+ define Content_Type_override_file configuration/overrides/${resourse}/Content-Type
+ ifelse { s6-test -f ${Content_Type_override_file} -a -r ${Content_Type_override_file} }
+ {
+ cat ${Content_Type_override_file}
+ }
+
backtick -D "no.extension" -n extension {
pipeline { printenv resource }
# strip everything up to the non-periods after the final
# with `Content-Type` `${1}/${2}`. colons in the extension are
# transformed into periods, allowing files like
# `index.text=x:market` being served as `text/x.market`
- #
- # this overrides any other Content-Type determination mechanism
ifelse {
pipeline { printenv extension }
# this regex matches exactly what `publicfile` does
- #
grep -s "[a-zA-Z0-9]+=[^=]+$"
}
{