From 16b24c86cecec0697b35ac321cddd500bc9cfdea Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 5 Jan 2011 10:54:45 -0800 Subject: tests: ensure 416 responses do keepalive This is useful for clients that specify a bad range, we can preserve the connection for them to specify a good response. --- t/byte-range-common.sh | 21 +++++++++++++++++++++ t/t0022-copy_stream-byte-range.sh | 2 +- t/t0023-sendfile-byte-range.sh | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 't') diff --git a/t/byte-range-common.sh b/t/byte-range-common.sh index 14050cf..b4852a6 100644 --- a/t/byte-range-common.sh +++ b/t/byte-range-common.sh @@ -61,6 +61,27 @@ t_begin "crazy offset goes over" && { die "expected Content-Range: bytes */SIZE" } +t_begin "keepalive/pipelining is supported on 416 responses" && { + rm -f $tmp + ( + cat $fifo > $tmp & + printf 'GET /byte-range-common.sh HTTP/1.1\r\n' + printf 'Host: %s\r\n' $listen + printf 'Range: bytes=9999999999-9999999999\r\n\r\n' + printf 'GET /byte-range-common.sh HTTP/1.1\r\n' + printf 'Host: %s\r\n' $listen + printf 'Connection: close\r\n' + printf 'Range: bytes=0-0\r\n\r\n' + wait + ) | socat - TCP:$listen > $fifo + + < $tmp awk ' +/^HTTP\/1\.1 / && NR == 1 && $2 == 416 { first = $2 } +/^HTTP\/1\.1 / && NR != 1 && $2 == 206 { second = $2 } +END { exit((first == 416 && second == 206) ? 0 : 1) } + ' +} + t_begin "full request matches with explicit ranges" && { sha1="$(curl -v 2>$err $range_all -sSf $url | rsha1)" check_content_range diff --git a/t/t0022-copy_stream-byte-range.sh b/t/t0022-copy_stream-byte-range.sh index e4fcdbf..7539c02 100755 --- a/t/t0022-copy_stream-byte-range.sh +++ b/t/t0022-copy_stream-byte-range.sh @@ -17,7 +17,7 @@ ThreadSpawn|WriterThreadSpawn|ThreadPool|WriterThreadPool|Base) ;; ;; esac -t_plan 12 "IO.copy_stream byte range response for $model" +t_plan 13 "IO.copy_stream byte range response for $model" t_begin "setup and startup" && { rtmpfiles out err diff --git a/t/t0023-sendfile-byte-range.sh b/t/t0023-sendfile-byte-range.sh index 89fbd7a..81183c7 100755 --- a/t/t0023-sendfile-byte-range.sh +++ b/t/t0023-sendfile-byte-range.sh @@ -17,7 +17,7 @@ EventMachine|NeverBlock) *) ;; esac -t_plan 12 "sendfile byte range response for $model" +t_plan 13 "sendfile byte range response for $model" t_begin "setup and startup" && { rtmpfiles out err -- cgit v1.2.3-24-ge0c7