#! /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.