3 test -r random_blob || die
"random_blob required, run with 'make $0'"
5 t_plan
10 "rack.input read tests"
7 t_begin
"setup and startup" && {
8 rtmpfiles curl_out curl_err
10 unicorn
-E none
-D rack-input-tests.ru
-c $unicorn_config
11 blob_sha1
=$
(rsha1
< random_blob
)
12 blob_size
=$
(count_bytes
< random_blob
)
13 t_info
"blob_sha1=$blob_sha1"
17 t_begin
"corked identity request" && {
21 printf 'PUT / HTTP/1.0\r\n'
22 printf 'Content-Length: %d\r\n\r\n' $blob_size
26 ) |
( sleep 1 && socat
- TCP4
:$listen > $fifo )
27 test 1 -eq $
(grep $blob_sha1 $tmp |count_lines
)
28 test x
"$(cat $ok)" = xok
31 t_begin
"corked chunked request" && {
35 content-md5-put
< random_blob
38 ) |
( sleep 1 && socat
- TCP4
:$listen > $fifo )
39 test 1 -eq $
(grep $blob_sha1 $tmp |count_lines
)
40 test x
"$(cat $ok)" = xok
43 t_begin
"corked identity request (input#size first)" && {
47 printf 'PUT /size_first HTTP/1.0\r\n'
48 printf 'Content-Length: %d\r\n\r\n' $blob_size
52 ) |
( sleep 1 && socat
- TCP4
:$listen > $fifo )
53 test 1 -eq $
(grep $blob_sha1 $tmp |count_lines
)
54 test x
"$(cat $ok)" = xok
57 t_begin
"corked identity request (input#rewind first)" && {
61 printf 'PUT /rewind_first HTTP/1.0\r\n'
62 printf 'Content-Length: %d\r\n\r\n' $blob_size
66 ) |
( sleep 1 && socat
- TCP4
:$listen > $fifo )
67 test 1 -eq $
(grep $blob_sha1 $tmp |count_lines
)
68 test x
"$(cat $ok)" = xok
71 t_begin
"corked chunked request (input#size first)" && {
75 printf 'PUT /size_first HTTP/1.1\r\n'
76 printf 'Host: example.com\r\n'
77 printf 'Transfer-Encoding: chunked\r\n'
78 printf 'Trailer: Content-MD5\r\n'
80 content-md5-put
--no-headers < random_blob
83 ) |
( sleep 1 && socat
- TCP4
:$listen > $fifo )
84 test 1 -eq $
(grep $blob_sha1 $tmp |count_lines
)
85 test 1 -eq $
(grep $blob_sha1 $tmp |count_lines
)
86 test x
"$(cat $ok)" = xok
89 t_begin
"corked chunked request (input#rewind first)" && {
93 printf 'PUT /rewind_first HTTP/1.1\r\n'
94 printf 'Host: example.com\r\n'
95 printf 'Transfer-Encoding: chunked\r\n'
96 printf 'Trailer: Content-MD5\r\n'
98 content-md5-put
--no-headers < random_blob
101 ) |
( sleep 1 && socat
- TCP4
:$listen > $fifo )
102 test 1 -eq $
(grep $blob_sha1 $tmp |count_lines
)
103 test x
"$(cat $ok)" = xok
106 t_begin
"regular request" && {
107 curl
-sSf -T random_blob http
://$listen/ > $curl_out 2> $curl_err
108 test x
$blob_sha1 = x$
(cat $curl_out)
112 t_begin
"chunked request" && {
113 curl
-sSf -T- < random_blob http
://$listen/ > $curl_out 2> $curl_err
114 test x
$blob_sha1 = x$
(cat $curl_out)
120 t_begin
"shutdown" && {