# 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
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
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}
\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
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
importas -i resource resource
}
-backtick -n header-directory {
+backtick -x -n header-directory {
# for status code pages specifically
ifelse {
s6-test \${#} != 0
# (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
#
#
# 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
# 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
}
#### 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
# 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")
# 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 }