From 70cc941643ccd3824091443df008bfda7765a2f9 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 14 Jul 2010 14:04:47 +0200 Subject: htgen-plain: initial commit --- htgen-plain | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 htgen-plain (limited to 'htgen-plain') diff --git a/htgen-plain b/htgen-plain new file mode 100755 index 0000000..659576f --- /dev/null +++ b/htgen-plain @@ -0,0 +1,94 @@ +#! /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 -- cgit v1.2.3