# set -o posix # ksh, not portable
setopt -o OCTAL_ZEROES 2>&-
+BR="$(printf '\n')"
+CR="$(printf '\r')"
+
+if [ "$1" = '--inetd' -a -z "$REQUEST_METHOD" ]; then
+ REMOTE_ADDR="$TCPREMOTEIP"
+ SERVER_NAME="$TCPLOCALIP"
+ SERVER_PORT="$TCPLOCALPORT"
+
+ read REQUEST_METHOD REQUEST_URI SERVER_PROTOCOL
+ PATH_INFO="${REQUEST_URI%\?*}"
+ QUERY_STRING="${REQUEST_URI#*\?}"
+ HTTP_HEADERS="$(sed -u '/^\r\?$/q')"
+
+ HTTP_CONTENT_LENGTH="$(printf %s "$HTTP_HEADERS" |grep -oiE '^Content-Length: [0-9]+')"
+ HTTP_CONTENT_LENGTH="${HTTP_CONTENT_LENGTH%%: *}"
+ HTTP_COOKIE="$(printf %s "$HTTP_HEADERS" |grep -oiE '^Cookie: [^\r]+')"
+ HTTP_COOKIE="${HTTP_COOKIE%%: *}"
+
+ export REMOTE_ADDR SERVER_NAME SERVER_PORT REQUEST_METHOD REQUEST_URI SERVER_PROTOCOL \
+ PATH_INFO QUERY_STRING HTTP_CONTENT_LENGTH HTTP_COOKIE
+
+ . "$0" |sed '1{s;^Status: ;HTTP/1.0 ;; t; iHTTP/1.0 200 OK\r
+ }'
+ exit $?
+fi
+
if [ "$REQUEST_METHOD" = POST -a "${HTTP_CONTENT_LENGTH:=${CONTENT_LENGTH:=0}}" -gt 0 ]; then
cgilite_post="$(head -c "$HTTP_CONTENT_LENGTH")"
fi
printf 'Status: 303 See Other\r\nLocation: %s\r\n\r\n' "$*"
exit 0
}
+