#!/bin/sh

set -e

node debian/tests/express-dos.js &
PID=$!
sleep 1
HEADERS=`mktemp`

curl --data-raw `perl -le 'print "[".chr(128)."]"'` -D $HEADERS -H 'Content-Type: application/json' http://localhost:56056/test
curl -d name=val http://localhost:56056/test

grep 400 $HEADERS

CODE=0
wait $PID || CODE=$?

echo "express app exited with code $CODE"
exit $CODE
