]> cat aescling's git repositories - httpd-execline.git/commitdiff
update for breaking changes in execline
authorsingle-right-quote <34298117+single-right-quote@users.noreply.github.com>
Mon, 23 Aug 2021 12:58:17 +0000 (08:58 -0400)
committersingle-right-quote <34298117+single-right-quote@users.noreply.github.com>
Tue, 24 Aug 2021 04:22:02 +0000 (04:22 +0000)
+ `backtick -i` is now the default behaviour
+ `backtick -I` is now the old default behaviour
+ `backtick -x` is now what `-I` used to be
+ `backtick -E` was added to automatically `import -i -u`
+ `trap` no longer supports timeouts; switch to timeout(1p)

visible-to-httpd/binaries/get-line-from-client.execline
visible-to-httpd/binaries/http-error-response.execline
visible-to-httpd/binaries/http-get-extra-headers.execline
visible-to-httpd/binaries/http-header-parse.execline
visible-to-httpd/binaries/http-start-line-parse.execline
visible-to-httpd/binaries/httpd.execline

index f8c18c0933e34b2d9ed6b228b2f13b75f1266704..d0cdc267584a57fb6e38446f19c61d048f1b1629 100755 (executable)
@@ -2,11 +2,6 @@
 # wrapper around plan 9 read(1) to timeout after 60 seconds
 # returns read(1)'s exit status
 
-trap -x -t 60000 {
-       timeout {
-               importas -i -u ! !
-               kill -- ${!}
-       }
-}
-pipeline -w { tr -d "\r" }
-read
+timeout --foreground --preserve-status 60
+       pipeline -w { tr -d "\r" }
+       read
index cc9f6db49c1418fe5d258ae88505171f76edef3f..d0e704f9fe78b8a0a54fe9c21c70be796d0bf6e6 100755 (executable)
@@ -10,8 +10,8 @@ foreground {
                log.execline "fatal: ??"${1}"??: "${3}
 }
 
-backtick -i -n Date { date -u "+%a, %d %b %Y %T GMT" }
-backtick -i -n extra_headers { http-get-extra-headers.execline ${1} }
+backtick -n Date { date -u "+%a, %d %b %Y %T GMT" }
+backtick -n extra_headers { http-get-extra-headers.execline ${1} }
 
 multisubstitute {
        importas -i -u Date Date
@@ -19,7 +19,7 @@ multisubstitute {
        importas -D "?? no hostname ??" hostname http_header_parse_Host
 }
 
-backtick -I -n error_response_directory {
+backtick -x -n error_response_directory {
        ifelse {
                s6-test -d configuration/error_response_pages/${hostname}/${1}
                        -a -r configuration/error_response_pages/${hostname}/${1}
@@ -61,13 +61,12 @@ Date: "${Date}"\r
 \r
 "
                }
-               
                cat message_body
        }
                # default: no error status page on file; use a hardcoded default
 
                # (why does `hoc -e` not work?)
-               backtick -i -n Content-Length {
+               backtick -n -E Content-Length {
                        backtick -i -n message_length {
                                pipeline { s6-echo -n -- ${2} }
                                wc -c
@@ -77,7 +76,6 @@ Date: "${Date}"\r
                        pipeline { s6-echo -- ${message_length}"*2 + 288" }
                        hoc
                }
-               importas -i -u Content-Length Content-Length
 
                if {
                        s6-echo -n -- "HTTP/1.1 "${1}" "${2}"\r
index db792cf1e48c0c0de1bbd4b1b96107a57ed2f5a0..45b56c3889bd7cd849c9de86cced8dd409323dcf 100755 (executable)
@@ -21,7 +21,7 @@ multisubstitute {
        importas -i resource resource
 }
 
-backtick -n header-directory {
+backtick -x -n header-directory {
        # for status code pages specifically
        ifelse {
                s6-test \${#} != 0
index 09d9a580121614d3b2069df2a39acd7d1fabbfdf..26e6b0c6544499e50c8172dd18f5cd4fe0919ac4 100755 (executable)
@@ -60,7 +60,7 @@ emptyenv -P
 # (deliberately) very underpowered)
 #
 
-backtick -i -n current_line { get-line-from-client.execline }
+backtick -n current_line { get-line-from-client.execline }
 
 ### terminating case: empty line
 #
@@ -91,13 +91,13 @@ ifelse {
 #
 # after parsing, exec(3p) this script with the hostname validating
 # subscript, then the remaing program, as arguments
-# 
-backtick -I -n header_name {
+#
+backtick -x -n header_name {
        pipeline { printenv current_line }
        pipeline { sed -n "s/^([^ :]+):.*/\\1/p" }
        read
 }
-backtick -I -n header_contents {
+backtick -x -n header_contents {
        pipeline { printenv current_line }
        # strip spaces or tabs from end of line  
        # then print the second token verbatim  
index e76fd3c8acd7850680002def9ede51083c97e312..a358a1a1cd80aaa2fe04585c30f0fa2113060f50 100755 (executable)
 # containing the request's method, requested resource, and http version
 # it then exec(3p)s into its command line
 
-backtick -i -n start_line { get-line-from-client.execline }
-backtick -I -n http_start_line_parse_method {
+backtick -n start_line { get-line-from-client.execline }
+backtick -x -n http_start_line_parse_method {
        pipeline { printenv start_line }
        pipeline { sed -n "s@^(CONNECT|DELETE|GET|HEAD|OPTIONS|PATCH|POST|PUT|TRACE) +.*@\\1@p" }
        read
 }
-backtick -I -n http_start_line_parse_resource {
+backtick -x -n http_start_line_parse_resource {
        pipeline { printenv start_line }
        pipeline { sed -n "s@^[^ ]+ +(/[^ ]*) +.*@\\1@p" }
        read
 }
-backtick -I -n http_start_line_parse_version {
+backtick -x -n http_start_line_parse_version {
        pipeline { printenv start_line }
        pipeline { sed -n "s@.*HTTP/([0-9]\.[0-9]) *@\\1@p" }
        read
index ed8c6c0c094862439748aa5c3415e9eb2c5a39cf..f8ee5754cb09bfd7ab76a084dbba01187db89185 100755 (executable)
@@ -103,11 +103,11 @@ if -X -n -t {
        }
 
        #### 3. process requested resource ###
-       backtick -i -n resource {
+       backtick -n resource {
                cd supported_domains
 
-               backtick -i -n candidate_resource {
-                       backtick -in with_dot_and_dot_dot {
+               backtick -n candidate_resource {
+                       backtick -n with_dot_and_dot_dot {
                                pipeline { s6-echo -n -- ${requested_resource} }
                                #
                                # strip query string, or resource location
@@ -195,7 +195,7 @@ if -X -n -t {
        # TODO: separate this out, ideally make reusable
 
        # file length in bytes: SHOULD be provided
-       backtick -i -n Content-Length { stat -c%s -- supported_domains/${resource} }
+       backtick -n Content-Length { stat -c%s -- supported_domains/${resource} }
 
        # "[weekday], [month-day] [month] [year] [hours:minutes:seconds] GMT"  
        # (example: "Tue, 03 Mar 2020 21:06:08 GMT")
@@ -203,20 +203,19 @@ if -X -n -t {
 
        # the date the resource was last modified SHOULD be provided
        backtick -i -n Last-Modified {
-               backtick -i -n seconds_since_epoch { stat -c %Y -- supported_domains/${resource} }
-               importas -i -u seconds_since_epoch seconds_since_epoch
+               backtick -n -E seconds_since_epoch { stat -c %Y -- supported_domains/${resource} }
                date -d @${seconds_since_epoch} -u ${date_format}
        }
 
        # current time of response: SHOULD be provided (why?)
-       backtick -i -n Date { date -u ${date_format} }
+       backtick -n Date { date -u ${date_format} }
 
        # allow for arbitrary HTTP header and HTTP status code overrides.
        # for an example where the former might be useful, consider Content
        # Security Policy; for the latter, consider HTTP 301 redirects
        #
        # be warned!! we do not validate these overrides!
-       backtick -i -n extra_headers { http-get-extra-headers.execline }
+       backtick -n extra_headers { http-get-extra-headers.execline }
 
        backtick -D "200 ok" -n status_code_and_message {
                if { s6-test -r configuration/overrides/${resource}/status_code }