Mercurial > hg > nginx-tests
annotate proxy_request_buffering_chunked.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 882267679006 |
children |
rev | line source |
---|---|
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Sergey Kandaurov |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 # (C) Nginx, Inc. |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 # Tests for unbuffered request body, chunked transfer-encoding. |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 ############################################################################### |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use warnings; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 use strict; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 use Test::More; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use Socket qw/ CRLF /; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 ############################################################################### |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
568
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
545
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(22); |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 $t->write_file_expand('nginx.conf', <<'EOF'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
42 listen 127.0.0.1:8080; |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 client_header_buffer_size 1k; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 proxy_request_buffering off; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 proxy_http_version 1.1; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 location / { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 client_body_buffer_size 2k; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 add_header X-Body "$request_body"; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
52 proxy_pass http://127.0.0.1:8081; |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 location /small { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 client_body_in_file_only on; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
56 proxy_pass http://127.0.0.1:8080/; |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 location /single { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 client_body_in_single_buffer on; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 add_header X-Body "$request_body"; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
61 proxy_pass http://127.0.0.1:8081; |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 location /discard { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 return 200 "TEST\n"; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 location /preread { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
67 proxy_pass http://127.0.0.1:8082/; |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 location /error_page { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
70 proxy_pass http://127.0.0.1:8081/404; |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 error_page 404 /404; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 proxy_intercept_errors on; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 location /404 { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 return 200 "$request_body\n"; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
80 listen 127.0.0.1:8081; |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 server_name localhost; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 location / { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
84 proxy_pass http://127.0.0.1:8080/discard; |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 location /404 { } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 EOF |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
568
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
545
diff
changeset
|
92 $t->run(); |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 ############################################################################### |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 unlike(http_get('/'), qr/X-Body:/ms, 'no body'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 like(http_get_body('/', '0123456789'), |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 qr/X-Body: 0123456789\x0d?$/ms, 'body'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 like(http_get_body('/', '0123456789' x 128), |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 qr/X-Body: (0123456789){128}\x0d?$/ms, 'body in two buffers'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 like(http_get_body('/single', '0123456789' x 128), |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 qr/X-Body: (0123456789){128}\x0d?$/ms, 'body in single buffer'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 like(http_get_body('/error_page', '0123456789'), |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 qr/^0123456789$/m, 'body in error page'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 # pipelined requests |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 like(http_get_body('/', '0123456789', '0123456789' x 128, '0123456789' x 512, |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 'foobar'), qr/X-Body: foobar\x0d?$/ms, 'body pipelined'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 like(http_get_body('/', '0123456789' x 128, '0123456789' x 512, '0123456789', |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 'foobar'), qr/X-Body: foobar\x0d?$/ms, 'body pipelined 2'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 like(http_get_body('/discard', '0123456789', '0123456789' x 128, |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 '0123456789' x 512, 'foobar'), qr/(TEST.*){4}/ms, |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 'body discard'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 like(http_get_body('/discard', '0123456789' x 128, '0123456789' x 512, |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 '0123456789', 'foobar'), qr/(TEST.*){4}/ms, |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 'body discard 2'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 # proxy with file only is disabled in unbuffered mode |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 like(http_get_body('/small', '0123456789'), |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 qr/X-Body: 0123456789\x0d?$/ms, 'small body in file only'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 # interactive tests |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
131 my $s = get_body('/preread', port(8082)); |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 ok($s, 'no preread'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 SKIP: { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 skip 'no preread failed', 3 unless $s; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 is($s->{upload}('01234'), '5' . CRLF . '01234' . CRLF, |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 'no preread - body part'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 is($s->{upload}('56789', last => 1), |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 '5' . CRLF . '56789' . CRLF . '0' . CRLF . CRLF, |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 'no preread - body part 2'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 like($s->{http_end}(), qr/200 OK/, 'no preread - response'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
147 $s = get_body('/preread', port(8082), '01234'); |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 ok($s, 'preread'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 SKIP: { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 skip 'preread failed', 3 unless $s; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 is($s->{preread}, '5' . CRLF . '01234' . CRLF, 'preread - preread'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 is($s->{upload}('56789', last => 1), |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 '5' . CRLF . '56789' . CRLF . '0' . CRLF . CRLF, 'preread - body'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 like($s->{http_end}(), qr/200 OK/, 'preread - response'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
161 $s = get_body('/preread', port(8082), '01234', many => 1); |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 ok($s, 'chunks'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 SKIP: { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 skip 'chunks failed', 3 unless $s; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 is($s->{preread}, '9' . CRLF . '01234many' . CRLF, 'chunks - preread'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 is($s->{upload}('56789', many => 1, last => 1), |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 '9' . CRLF . '56789many' . CRLF . '0' . CRLF . CRLF, 'chunks - body'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 like($s->{http_end}(), qr/200 OK/, 'chunks - response'); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 ############################################################################### |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 sub http_get_body { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 my $uri = shift; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 my $last = pop; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 return http( join '', (map { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 my $body = $_; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 "GET $uri HTTP/1.1" . CRLF |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 . "Host: localhost" . CRLF |
545
dbf8fb0f3d30
Tests: fixed unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
542
diff
changeset
|
184 . "Transfer-Encoding: chunked" . CRLF . CRLF |
dbf8fb0f3d30
Tests: fixed unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
542
diff
changeset
|
185 . sprintf("%x", length $body) . CRLF |
dbf8fb0f3d30
Tests: fixed unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
542
diff
changeset
|
186 . $body . CRLF |
dbf8fb0f3d30
Tests: fixed unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
542
diff
changeset
|
187 . "0" . CRLF . CRLF |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 } @_), |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 "GET $uri HTTP/1.1" . CRLF |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 . "Host: localhost" . CRLF |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 . "Connection: close" . CRLF |
545
dbf8fb0f3d30
Tests: fixed unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
542
diff
changeset
|
192 . "Transfer-Encoding: chunked" . CRLF . CRLF |
dbf8fb0f3d30
Tests: fixed unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
542
diff
changeset
|
193 . sprintf("%x", length $last) . CRLF |
dbf8fb0f3d30
Tests: fixed unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
542
diff
changeset
|
194 . $last . CRLF |
dbf8fb0f3d30
Tests: fixed unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
542
diff
changeset
|
195 . "0" . CRLF . CRLF |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 ); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 sub get_body { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 my ($url, $port, $body, %extra) = @_; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 my ($server, $client, $s); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 my ($last, $many) = (0, 0); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 $last = $extra{last} if defined $extra{last}; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
205 $many = $extra{many} if defined $extra{many}; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
206 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
207 $server = IO::Socket::INET->new( |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
208 Proto => 'tcp', |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
209 LocalHost => '127.0.0.1', |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
210 LocalPort => $port, |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
211 Listen => 5, |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
212 Reuse => 1 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
213 ) |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
214 or die "Can't create listening socket: $!\n"; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
215 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
216 my $r = <<EOF; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
217 GET $url HTTP/1.1 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
218 Host: localhost |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 Connection: close |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 Transfer-Encoding: chunked |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
221 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
222 EOF |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
223 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
224 if (defined $body) { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
225 $r .= sprintf("%x", length $body) . CRLF; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
226 $r .= $body . CRLF; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
227 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
228 if (defined $body && $many) { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
229 $r .= sprintf("%x", length 'many') . CRLF; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
230 $r .= 'many' . CRLF; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
231 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
232 if ($last) { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
233 $r .= "0" . CRLF . CRLF; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
234 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
235 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 $s = http($r, start => 1); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
237 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
238 eval { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
239 local $SIG{ALRM} = sub { die "timeout\n" }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
240 local $SIG{PIPE} = sub { die "sigpipe\n" }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
241 alarm(5); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
242 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
243 $client = $server->accept(); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
244 |
837
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
245 log2c("(new connection $client)"); |
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
246 |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
247 alarm(0); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
248 }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
249 alarm(0); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
250 if ($@) { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
251 log_in("died: $@"); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
252 return undef; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
253 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
254 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
255 $client->sysread(my $buf, 1024); |
837
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
256 log2i($buf); |
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
257 |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
258 $buf =~ s/.*?\x0d\x0a?\x0d\x0a?(.*)/$1/ms; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
259 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
260 my $f = { preread => $buf }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
261 $f->{upload} = sub { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
262 my ($body, %extra) = @_; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
263 my ($last, $many) = (0, 0); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
264 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
265 $last = $extra{last} if defined $extra{last}; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
266 $many = $extra{many} if defined $extra{many}; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
267 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
268 my $buf = sprintf("%x", length $body) . CRLF; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
269 $buf .= $body . CRLF; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
270 if ($many) { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
271 $buf .= sprintf("%x", length 'many') . CRLF; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
272 $buf .= 'many' . CRLF; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
273 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
274 if ($last) { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
275 $buf .= "0" . CRLF . CRLF; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
276 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
277 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
278 eval { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
279 local $SIG{ALRM} = sub { die "timeout\n" }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
280 local $SIG{PIPE} = sub { die "sigpipe\n" }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
281 alarm(5); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
282 |
837
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
283 log_out($buf); |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
284 $s->write($buf); |
837
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
285 |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
286 $client->sysread($buf, 1024); |
837
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
287 log2i($buf); |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
288 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
289 alarm(0); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
290 }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
291 alarm(0); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
292 if ($@) { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
293 log_in("died: $@"); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
294 return undef; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
295 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
296 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
297 return $buf; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
298 }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
299 $f->{http_end} = sub { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
300 my $buf = ''; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
301 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
302 $client->write(<<EOF); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
303 HTTP/1.1 200 OK |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
304 Connection: close |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
305 X-Port: $port |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
306 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
307 OK |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
308 EOF |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
309 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
310 $client->close; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
311 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
312 eval { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
313 local $SIG{ALRM} = sub { die "timeout\n" }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
314 local $SIG{PIPE} = sub { die "sigpipe\n" }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
315 alarm(5); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
316 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
317 $s->sysread($buf, 1024); |
837
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
318 log_in($buf); |
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
319 |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
320 $s->close(); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
321 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
322 alarm(0); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
323 }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
324 alarm(0); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
325 if ($@) { |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
326 log_in("died: $@"); |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
327 return undef; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
328 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
329 |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
330 return $buf; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
331 }; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
332 return $f; |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
333 } |
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
334 |
837
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
335 sub log2i { Test::Nginx::log_core('|| <<', @_); } |
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
336 sub log2o { Test::Nginx::log_core('|| >>', @_); } |
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
337 sub log2c { Test::Nginx::log_core('||', @_); } |
68a6678abae2
Tests: improved logging for unbuffered request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
338 |
542
e7e3ced702f5
Tests: unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
339 ############################################################################### |