]> cat aescling's git repositories - httpd-execline.git/commitdiff
allow configuring domain-name–agnostic error response pages
authorsingle-right-quote <34298117+single-right-quote@users.noreply.github.com>
Thu, 24 Sep 2020 19:42:40 +0000 (19:42 +0000)
committersingle-right-quote <34298117+single-right-quote@users.noreply.github.com>
Thu, 24 Sep 2020 19:43:23 +0000 (19:43 +0000)
additionally, remove outdated comments.

README.md
visible-to-httpd/binaries/http-error-response.execline

index d95461e401d3a9e45f522cd1e032fd16b19190b8..7cb73c832240eaff0b102448a8c6b65fc97b09e7 100644 (file)
--- 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/` ###
index f749eca8be6b1fab531e60660c8bd498aea94056..cc9f6db49c1418fe5d258ae88505171f76edef3f 100755 (executable)
@@ -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 }