Rainbows! 0.2.0
[rainbows.git] / t / t0000-basic.sh
blob1ba3f43e77a4973fef8abb00ffc293c5f281ea5e
1 #!/bin/sh
2 . ./test-lib.sh
4 eval $(unused_listen)
5 rtmpfiles pid tmp ok fifo
7 rm -f $fifo
8 mkfifo $fifo
10 rainbows -D t0000.ru -l $listen --pid $pid &
11 wait_for_pid $pid
13 echo "single request"
14 curl -sSfv http://$listen/
16 echo "two requests with keepalive"
17 curl -sSfv http://$listen/a http://$listen/b > $tmp 2>&1
18 grep 'Re-using existing connection' < $tmp
20 echo "pipelining partial requests"
21 req='GET / HTTP/1.1\r\nHost: foo\r\n'
23 printf "$req"'\r\n'"$req"
24 cat $fifo > $tmp &
25 sleep 1
26 printf 'Connection: close\r\n\r\n'
27 echo ok > $ok
28 ) | socat - TCP:$listen > $fifo
30 kill $(cat $pid)
32 # sed -ne 's/^/------/p' < $tmp
33 test 2 -eq $(grep '^HTTP/1.1' $tmp | wc -l)
34 test 2 -eq $(grep '^HTTP/1.1 200 OK' $tmp | wc -l)
35 test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l)
36 test 1 -eq $(grep '^Connection: close' $tmp | wc -l)
37 test x"$(cat $ok)" = xok