. vars.inc 

PRINTF=/usr/bin/printf
FMT="%s %s HTTP/1.0\r\nHost: %s\r\n"
AUTH="Authorization: Basic Zm9vOmJhcmJhcg==\r\n"
NC=/usr/bin/nc
BAD_METHODS="PUT DELETE OPTIONS TRACE PATCH" # CONNECT require ssl or proxy

BAD_CODE=501

pgrep -f -q "mohawk.*${REQUIRED_CMDLINE}" || {
	echo "mohawk with ${REQUIRED_CMDLINE} not running. Exit"
	exit 1
}

do_request()
{
	local ports=${PORTS:-$UNPRIVILIGED_PORT}
	local methods=${METHODS:-"HEAD GET POST"}
	local awk_file=${AWK_FILE:-http.awk}

	echo "$NAME (${CODE}):"
	for port in ${ports}; do
		for method in ${methods}; do
			echo -n "${method} http://${HOST}:${port}${WPATH} => "
			${PRINTF} "${FMT}$@\r\n" ${method} ${WPATH} ${HOST} | ${NC} localhost ${port} | awk -v code=${CODE} -f ${awk_file} || exit 1
		done
	done
	echo
}

# vim: set ft=sh sw=4 sts=4 ts=4 :
