#! /bin/sh # vim:set fdm=marker: set -euf Server='htgen-plain/1.0' ## htgen --serve {{{ case $# in (1) case "$1" in (--serve) HTGEN_HOST="${HTGEN_HOST-0.0.0.0}" HTGEN_PORT="${HTGEN_PORT-42380}" TCPSERVER_OPTS='-c 423 -t 2 -D' echo "#### $Server $HTGEN_HOST:$HTGEN_PORT" >&2 exec tcpserver $TCPSERVER_OPTS "$HTGEN_HOST" "$HTGEN_PORT" "$0" ## this should not happen... exit 23 esac esac ## }}} ## reply_404 {{{ reply_404() { cat<&2<&2 # cat>&2<&2<&2 ## Parse HTTP_Headers into Variables. eval "$( echo "$HTTP_Headers" | sed -r ' ## TODO concatenate lines /^[^:]+-[^:]+:/s/^([a-zA-Z-]+):[[:space:]]*([^'\'']*)*$/\ x=`echo \1 | tr - _`; \ echo $x=\\'\'''\''\2'\''\\'\''\\;;\ echo HTTP_Header_Variables=\\\${HTTP_Header_Variables+\\\$HTTP_Header_Variables:}$x\\;;\ /;t s/^([a-zA-Z]+):[[:space:]]*([^'\'']*)*$/\ echo \1=\\'\'''\''\2'\''\\'\''\\;;\ echo HTTP_Header_Variables=\\\${HTTP_Header_Variables+\\\$HTTP_Header_Variables:}\1\\;;\ /;t s/^.*/# &/ '| sh)" >&2 echo >&2 ## }}} reply_404 exit