From: single-right-quote <34298117+single-right-quote@users.noreply.github.com> Date: Thu, 24 Sep 2020 19:42:40 +0000 (+0000) Subject: allow configuring domain-name–agnostic error response pages X-Git-Tag: v1.0.0~42 X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=c0d138b3fc67b8a49018f5e42428a6d46edc7930;p=httpd-execline.git allow configuring domain-name–agnostic error response pages additionally, remove outdated comments. --- diff --git a/README.md b/README.md index d95461e..7cb73c8 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ an HTML file, write the contents of said file at and place `text/html` in a file `Content-Type` in the same folder. the error response code has a generic fallback built into the script. -there really should be support for a `-fallback` domain like with +you can override this using a `-fallback` domain folder, like with domain-level `default_headers`. #### `./visible-to-httpd/configuration/error_response_pages/` ### diff --git a/visible-to-httpd/binaries/http-error-response.execline b/visible-to-httpd/binaries/http-error-response.execline index f749eca..cc9f6db 100755 --- a/visible-to-httpd/binaries/http-error-response.execline +++ b/visible-to-httpd/binaries/http-error-response.execline @@ -3,10 +3,6 @@ # # if `configuration/status-code/table/${hostname}/${STATUS_CODE} exists, `cat(1)` that # otherwise, fall back on a very generic error message -# -# TODO: -# + handle headers for custom status code files -# + related to above: get `Content-Length` correct fdclose 0 foreground { @@ -23,14 +19,30 @@ multisubstitute { importas -D "?? no hostname ??" hostname http_header_parse_Host } -if { - # if there is an error response page for this status code: +backtick -I -n error_response_directory { ifelse { s6-test -d configuration/error_response_pages/${hostname}/${1} -a -r configuration/error_response_pages/${hostname}/${1} } { - cd configuration/error_response_pages/${hostname}/${1} + s6-echo -n -- configuration/error_response_pages/${hostname}/${1} + } + ifelse { + s6-test -d configuration/error_response_pages/-fallback/${1} + -a -r configuration/error_response_pages/-fallback/${1} + } + { + s6-echo -n -- configuration/error_response_pages/-fallback/${1} + } + exit 1 +} + +if { + # if there is an error response page for this status code: + ifelse { s6-test -v error_response_directory } + { + importas -i -u error_response_directory error_response_directory + cd ${error_response_directory} backtick -D "application/xhtml+xml; charset=utf-8" -n Content-Type { cat Content-Type } backtick -i -n Content-Length { wc -c message_body }