CR="$(printf '\r')"
if [ "$1" = '--inetd' -a -z "$REQUEST_METHOD" ]; then
- REMOTE_ADDR="$TCPREMOTEIP"
- SERVER_NAME="$TCPLOCALIP"
- SERVER_PORT="$TCPLOCALPORT"
+ REMOTE_ADDR="${TCPREMOTEIP:-$NCAT_REMOTE_ADDR}"
+ SERVER_NAME="${TCPLOCALIP:-$NCAT_LOCAL_ADDR}"
+ SERVER_PORT="${TCPLOCALPORT:-$NCAT_LOCAL_PORT}"
read REQUEST_METHOD REQUEST_URI SERVER_PROTOCOL
PATH_INFO="${REQUEST_URI%\?*}"
QUERY_STRING="${REQUEST_URI#*\?}"
- HTTP_HEADERS="$(sed -u '/^\r\?$/q')"
+ cgilite_headers="$(sed -u '/^\r\?$/q')"
- HTTP_CONTENT_LENGTH="$(printf %s "$HTTP_HEADERS" |grep -oiE '^Content-Length: [0-9]+')"
- HTTP_CONTENT_LENGTH="${HTTP_CONTENT_LENGTH##*: }"
- HTTP_COOKIE="$(printf %s "$HTTP_HEADERS" |grep -oiE '^Cookie: [^\r]+')"
- HTTP_COOKIE="${HTTP_COOKIE##*: }"
+ HTTP_CONTENT_LENGTH="$(printf %s "$cgilite_headers" |grep -oiE '^Content-Length: [0-9]+')"
+ HTTP_CONTENT_LENGTH="${HTTP_CONTENT_LENGTH#*: }"
+ HTTP_COOKIE="$(printf %s "$cgilite_headers" |grep -oiE '^Cookie: [^\r]+')"
+ HTTP_COOKIE="${HTTP_COOKIE#*: }"
export REMOTE_ADDR SERVER_NAME SERVER_PORT REQUEST_METHOD REQUEST_URI SERVER_PROTOCOL \
PATH_INFO QUERY_STRING HTTP_CONTENT_LENGTH HTTP_COOKIE
REF(){ cgilite_value REF $@; }
REF_COUNT(){ cgilite_count REF $1; }
+HEADER(){
+ printf %s "$cgilite_headers" \
+ | sed -rn '/^'"${1}"': /{s;^[^:]+: ([^\r]+)\r?$;\1;p;q;}'
+}
+
COOKIE(){
printf "$(
printf %s " ${HTTP_COOKIE}" \