From 466b8c5103208e7393fdb710d275e7d687be2592 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 2 Feb 2010 04:49:37 +0100 Subject: Added default cases for $Host and $Method Added default case for $Host: Forbidded Added default case for $Method: Not Implemented Added preliminary Cache-Control --- htgen.sh | 116 ++++++++++++++++++++++++++++++++++++--------------------------- htgend | 3 +- 2 files changed, 69 insertions(+), 50 deletions(-) diff --git a/htgen.sh b/htgen.sh index c76283a..262e81b 100755 --- a/htgen.sh +++ b/htgen.sh @@ -2,8 +2,12 @@ set -euf +# TODO Cache-Control [RFC 2616, Section 14.9] +# TODO Accept-Encoding: gzip,deflate +# TODO Keep-Alive: 300 +# TODO Connection: keep-alive -Server='httpd-single/0.2' +Server='htgen' Request="$(sed 's/\r$//;/^$/q')" date="`date '+%Y-%m-%d %H:%M:%S'`" @@ -33,27 +37,28 @@ cat>&2<&2 - - # TODO Date: `date --utc` + +## +## Handle request. +## +if test -z "$Request_Line" ; then + echo "# FAIL" + exit -23 +fi >&2 - ## - ## Handle request. - ## - case "$Host" in - src.mine.nu:42380|src.mine.nu|vix|vix:42380|localhost:42380) - case "${Method-Invalid-Request}" in - GET|HEAD) - case "$Request_URI" in - /style5.css) - body_type=file - body=~/public_html$Request_URI - cat<&2 exit - -# tcpserver info: -# $PROTO is the string TCP. -# -# $TCPLOCALIP is the IP address of the local host, in dotted-decimal form. -# -# $TCPLOCALPORT is the local TCP port number, in decimal. -# -# $TCPLOCALHOST is the name listed in DNS for the local host. If no name is available, $TCPLOCALHOST is not set. Beware that $TCPLOCALHOST can contain arbitrary characters. -# -# $TCPREMOTEIP is the IP address of the remote host, in dotted-decimal form. -# -# $TCPREMOTEPORT is the remote TCP port number, in decimal. -# -# $TCPREMOTEHOST is the name listed in DNS for the remote host. If no name is available, $TCPREMOTEHOST is not set. Beware that $TCPREMOTEHOST can contain arbitrary characters. -# -# $TCPREMOTEINFO is a connection-specific string supplied by the remote host via the 931/1413/IDENT/TAP protocol. If no information is available, $TCPREMOTEINFO is not set. Beware that $TCPREMOTEINFO can contain arbitrary characters. diff --git a/htgend b/htgend index 9f3ba6f..0e4c668 100755 --- a/htgend +++ b/htgend @@ -1,7 +1,8 @@ #! /bin/sh set -euf HTGEN_PROG="${HTGEN_SH-$(dirname "$(readlink -f "$0")")/htgen.sh}" -HTGEN_HOST="${HTGEN_HOST-0}" +HTGEN_HOST="${HTGEN_HOST-0.0.0.0}" HTGEN_PORT="${HTGEN_PORT-42380}" TCPSERVER_OPTS='-c 423 -t 2 -D' +echo "#### htgend $HTGEN_HOST:$HTGEN_PORT" >&2 exec tcpserver $TCPSERVER_OPTS "$HTGEN_HOST" "$HTGEN_PORT" "$HTGEN_PROG" -- cgit v1.2.3