comparison body_chunked.t @ 1551:27237569776f

Tests: additional Transfer-Encoding and Host headers tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 27 Feb 2020 19:49:54 +0300
parents 5ae8e8feac36
children 5ac6efbe5552
comparison
equal deleted inserted replaced
1550:5c96745988c4 1551:27237569776f
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(13); 25 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(16);
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
169 169
170 # proxy_next_upstream 170 # proxy_next_upstream
171 171
172 like(http_get_body('/next', '0123456789'), 172 like(http_get_body('/next', '0123456789'),
173 qr/X-Body: 0123456789\x0d?$/ms, 'body chunked next upstream'); 173 qr/X-Body: 0123456789\x0d?$/ms, 'body chunked next upstream');
174
175 # invalid Transfer-Encoding
176
177 TODO: {
178 local $TODO = 'not yet' unless $t->has_version('1.17.9');
179
180 like(http_transfer_encoding('identity'), qr/501 Not Implemented/,
181 'transfer encoding identity');
182
183 like(http_transfer_encoding("chunked\nTransfer-Encoding: chunked"),
184 qr/400 Bad/, 'transfer encoding repeat');
185
186 }
187
188 like(http_transfer_encoding('chunked, identity'), qr/501 Not Implemented/,
189 'transfer encoding list');
174 190
175 ############################################################################### 191 ###############################################################################
176 192
177 sub read_body_file { 193 sub read_body_file {
178 my ($r) = @_; 194 my ($r) = @_;
205 . $last . CRLF 221 . $last . CRLF
206 . "0" . CRLF . CRLF 222 . "0" . CRLF . CRLF
207 ); 223 );
208 } 224 }
209 225
210 ############################################################################### 226 sub http_transfer_encoding {
227 my ($encoding) = @_;
228
229 http("GET / HTTP/1.1" . CRLF
230 . "Host: localhost" . CRLF
231 . "Connection: close" . CRLF
232 . "Transfer-Encoding: $encoding" . CRLF . CRLF
233 . "0" . CRLF . CRLF);
234 }
235
236 ###############################################################################