about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-07-19 10:09:57 +0000
committerEric Wong <normalperson@yhbt.net>2010-07-19 17:04:27 -0700
commit53b04c96d38bc6bb5fb3b4874fbf59aae81eb6f0 (patch)
treebf28e1cdefd32bcbe00fb892cade452e278f8f17 /t
parent1e6d3d19da2b62bfe7f8fd7827dcad3ee3fe9923 (diff)
downloadrainbows-53b04c96d38bc6bb5fb3b4874fbf59aae81eb6f0.tar.gz
This makes it easier to write proxies for slow clients that
benefit from keep-alive.  We also need to be careful about
non-HTTP/1.1 connections that can't do keepalive, now.
Diffstat (limited to 't')
-rwxr-xr-xt/t0030-fast-pipe-response.sh35
1 files changed, 31 insertions, 4 deletions
diff --git a/t/t0030-fast-pipe-response.sh b/t/t0030-fast-pipe-response.sh
index 5acbc01..f81029a 100755
--- a/t/t0030-fast-pipe-response.sh
+++ b/t/t0030-fast-pipe-response.sh
@@ -2,10 +2,10 @@
 . ./test-lib.sh
 test -r random_blob || die "random_blob required, run with 'make $0'"
 
-t_plan 6 "fast pipe response for $model"
+t_plan 10 "fast pipe response for $model"
 
 t_begin "setup and startup" && {
-        rtmpfiles err
+        rtmpfiles err out
         rainbows_setup $model
         rainbows -E none -D fast-pipe-response.ru -c $unicorn_config
         rainbows_wait_start
@@ -13,6 +13,7 @@ t_begin "setup and startup" && {
 
 t_begin "read random blob sha1" && {
         random_blob_sha1=$(rsha1 < random_blob)
+        three_sha1=$(cat random_blob random_blob random_blob | rsha1)
 }
 
 t_begin "single request matches" && {
@@ -25,12 +26,38 @@ t_begin "Content-Length header preserved in response" && {
         grep "^< Content-Length:" $err
 }
 
+t_begin "send three keep-alive requests" && {
+        sha1=$(curl -vsSf 2> $err \
+               http://$listen/ http://$listen/ http://$listen/ | rsha1)
+        test -n "$sha1"
+        test x"$sha1" = x"$three_sha1"
+}
+
+t_begin "ensure responses were all keep-alive" && {
+        test 3 -eq $(grep '< Connection: keep-alive' < $err | wc -l)
+}
+
+t_begin "HTTP/1.0 test" && {
+        sha1=$(curl -0 -v 2> $err -sSf http://$listen/ | rsha1)
+        test $sha1 = $random_blob_sha1
+        grep '< Connection: close' < $err
+}
+
+t_begin "HTTP/0.9 test" && {
+        (
+                printf 'GET /\r\n'
+                rsha1 < $fifo > $tmp &
+                wait
+                echo ok > $ok
+        ) | socat - TCP:$listen > $fifo
+        test $(cat $tmp) = $random_blob_sha1
+        test xok = x$(cat $ok)
+}
+
 t_begin "shutdown server" && {
         kill -QUIT $rainbows_pid
 }
 
-dbgcat r_err
-
 t_begin "check stderr" && check_stderr
 
 t_done