comparison body.t @ 271:1a6eef7ac914

Tests: test for r->request_body->buf incorrect reuse.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 20 Mar 2013 19:31:47 +0400
parents 970bb423e59f
children 202de1d281e5
comparison
equal deleted inserted replaced
270:f857180657c9 271:1a6eef7ac914
20 ############################################################################### 20 ###############################################################################
21 21
22 select STDERR; $| = 1; 22 select STDERR; $| = 1;
23 select STDOUT; $| = 1; 23 select STDOUT; $| = 1;
24 24
25 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(12); 25 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(13);
26 26
27 $t->write_file_expand('nginx.conf', <<'EOF'); 27 $t->write_file_expand('nginx.conf', <<'EOF');
28 28
29 %%TEST_GLOBALS%% 29 %%TEST_GLOBALS%%
30 30
60 add_header X-Body-File "$request_body_file"; 60 add_header X-Body-File "$request_body_file";
61 proxy_pass http://127.0.0.1:8081; 61 proxy_pass http://127.0.0.1:8081;
62 } 62 }
63 location /small { 63 location /small {
64 client_body_in_file_only on; 64 client_body_in_file_only on;
65 add_header X-Original-Uri "$request_uri";
65 proxy_pass http://127.0.0.1:8080/; 66 proxy_pass http://127.0.0.1:8080/;
66 } 67 }
67 location /single { 68 location /single {
68 client_body_in_single_buffer on; 69 client_body_in_single_buffer on;
69 add_header X-Body "$request_body"; 70 add_header X-Body "$request_body";
137 # proxy with file only 138 # proxy with file only
138 139
139 like(http_get_body('/small', '0123456789'), 140 like(http_get_body('/small', '0123456789'),
140 qr/X-Body: 0123456789\x0d?$/ms, 'small body in file only'); 141 qr/X-Body: 0123456789\x0d?$/ms, 'small body in file only');
141 142
143 # proxy with file only - reuse of r->header_in
144
145 like(
146 http(
147 'GET /small HTTP/1.0' . CRLF
148 . 'Content-Length: 10' . CRLF . CRLF
149 . '01234',
150 sleep => 0.1,
151 body => '56789'
152 ),
153 qr!X-Body: 0123456789\x0d?\x0a.*X-Original-Uri: /small!ms,
154 'small body in file only, not preread'
155 );
156
142 # proxy_next_upstream 157 # proxy_next_upstream
143 158
144 like(http_get_body('/next', '0123456789'), 159 like(http_get_body('/next', '0123456789'),
145 qr/X-Body: 0123456789\x0d?$/ms, 'body next upstream'); 160 qr/X-Body: 0123456789\x0d?$/ms, 'body next upstream');
146 161