From 7740117825f62a763be27a4656669d4a3debb6e0 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 2 Feb 2010 03:44:18 +0100 Subject: Initial commit. --- htgen.sh | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100755 htgen.sh diff --git a/htgen.sh b/htgen.sh new file mode 100755 index 0000000..c76283a --- /dev/null +++ b/htgen.sh @@ -0,0 +1,137 @@ +#! /bin/sh +set -euf + + + +Server='httpd-single/0.2' +Request="$(sed 's/\r$//;/^$/q')" +date="`date '+%Y-%m-%d %H:%M:%S'`" + +## +## Parse request. +## +Request_Line= +eval "$(echo "$Request" | sed -rn ' + 1{s^([a-zA-Z]+) ([a-zA-Z0-9?&+*/.-]+) HTTP/([0-9]+\.[0-9]+)$\ + Request_Line="&"\ + Method="\1"\ + Request_URI="\2"\ + HTTP_Version="\3"\ + p;t;i\ + Request_Line= # invalid request + q + } + s/^Host: ([a-zA-Z0-9?+&/:.-]+)$/Host="\1"/p +')" + +## +## Log request. +## +# TODO real logging +cat>&2<&2 + + # TODO Date: `date --utc` + + ## + ## 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. -- cgit v1.2.3