Mercurial > hg > nginx-tests
annotate body_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 | a095b971fbcc |
children |
rev | line source |
---|---|
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for nginx request body reading, with chunked transfer-coding. |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 use Socket qw/ CRLF /; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use lib 'lib'; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 use Test::Nginx; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 ############################################################################### |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 |
1954
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(24); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
242
diff
changeset
|
31 daemon off; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 events { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 http { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 |
269
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
39 upstream u { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
40 server 127.0.0.1:8082; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
41 server 127.0.0.1:8080 backup; |
269
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
42 } |
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
43 |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
45 listen 127.0.0.1:8080; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 server_name localhost; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 client_header_buffer_size 1k; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 location / { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 client_body_buffer_size 2k; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 add_header X-Body "$request_body"; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 add_header X-Body-File "$request_body_file"; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
54 proxy_pass http://127.0.0.1:8081; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 location /b { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 client_body_buffer_size 2k; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 client_body_in_file_only on; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 add_header X-Body "$request_body"; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 add_header X-Body-File "$request_body_file"; |
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; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 location /single { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 client_body_in_single_buffer on; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 add_header X-Body "$request_body"; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 add_header X-Body-File "$request_body_file"; |
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:8081; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 } |
1500
44ce08f5259f
Tests: client_max_body_size tests in body.t, body_chunked.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
69 location /large { |
44ce08f5259f
Tests: client_max_body_size tests in body.t, body_chunked.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
70 client_max_body_size 1k; |
1954
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
71 client_body_buffer_size 2k; |
1500
44ce08f5259f
Tests: client_max_body_size tests in body.t, body_chunked.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
72 proxy_pass http://127.0.0.1:8081; |
44ce08f5259f
Tests: client_max_body_size tests in body.t, body_chunked.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
73 } |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 location /discard { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 return 200 "TEST\n"; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 } |
269
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
77 location /next { |
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
78 proxy_pass http://u/; |
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
79 } |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
83 listen 127.0.0.1:8081; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 server_name localhost; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 location / { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 return 200 "TEST\n"; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 } |
269
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
90 |
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
91 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
92 listen 127.0.0.1:8082; |
269
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
93 server_name localhost; |
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
94 |
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
95 location / { |
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
96 return 444; |
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
97 } |
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
98 } |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 EOF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 $t->run(); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 ############################################################################### |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 like(http_get_body('/', '0123456789'), |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 qr/X-Body: 0123456789\x0d?$/ms, 'body'); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 like(http_get_body('/', '0123456789' x 128), |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 qr/X-Body: (0123456789){128}\x0d?$/ms, 'body in two buffers'); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 like(http_get_body('/', '0123456789' x 512), |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 qr/X-Body-File/ms, 'body in file'); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 like(read_body_file(http_get_body('/b', '0123456789' x 512)), |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 qr/^(0123456789){512}$/s, 'body in file only'); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 like(http_get_body('/single', '0123456789' x 128), |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 qr/X-Body: (0123456789){128}\x0d?$/ms, 'body in single buffer'); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 |
1500
44ce08f5259f
Tests: client_max_body_size tests in body.t, body_chunked.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
122 like(http_get_body('/large', '0123456789' x 128), qr/ 413 /, 'body too large'); |
1954
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
123 like(http_get_body('/large', 'X' x 1024), qr/ 200 /, 'body exact limit'); |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
124 like(http_get_body('/large', 'X' x 1025), qr/ 413 /, 'body just above limit'); |
1500
44ce08f5259f
Tests: client_max_body_size tests in body.t, body_chunked.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
125 |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 # pipelined requests |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 like(http_get_body('/', '0123456789', '0123456789' x 128, '0123456789' x 512, |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 'foobar'), qr/X-Body: foobar\x0d?$/ms, 'chunked body pipelined'); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 like(http_get_body('/', '0123456789' x 128, '0123456789' x 512, '0123456789', |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 'foobar'), qr/X-Body: foobar\x0d?$/ms, 'chunked body pipelined 2'); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 like(http_get_body('/discard', '0123456789', '0123456789' x 128, |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 '0123456789' x 512, 'foobar'), qr/(TEST.*){4}/ms, |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 'chunked body discard'); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 like(http_get_body('/discard', '0123456789' x 128, '0123456789' x 512, |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 '0123456789', 'foobar'), qr/(TEST.*){4}/ms, |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 'chunked body discard 2'); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 |
1501
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
140 # invalid chunks |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
141 |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
142 like( |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
143 http( |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
144 'GET / HTTP/1.1' . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
145 . 'Host: localhost' . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
146 . 'Connection: close' . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
147 . 'Transfer-Encoding: chunked' . CRLF . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
148 . '4' . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
149 . 'SEE-THIS' . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
150 . '0' . CRLF . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
151 ), |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
152 qr/400 Bad/, 'runaway chunk' |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
153 ); |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
154 |
1502
5ae8e8feac36
Tests: adjusted request body tests with invalid chunked body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1501
diff
changeset
|
155 like( |
1501
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
156 http( |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
157 'GET /discard HTTP/1.1' . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
158 . 'Host: localhost' . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
159 . 'Connection: close' . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
160 . 'Transfer-Encoding: chunked' . CRLF . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
161 . '4' . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
162 . 'SEE-THIS' . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
163 . '0' . CRLF . CRLF |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
164 ), |
1502
5ae8e8feac36
Tests: adjusted request body tests with invalid chunked body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1501
diff
changeset
|
165 qr/400 Bad/, 'runaway chunk discard' |
1501
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
166 ); |
91235919d80f
Tests: request body and invalid chunked transfer encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1500
diff
changeset
|
167 |
1954
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
168 # chunk extensions and trailers |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
169 |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
170 like( |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
171 http( |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
172 'GET /large HTTP/1.1' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
173 . 'Host: localhost' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
174 . 'Connection: close' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
175 . 'Transfer-Encoding: chunked' . CRLF . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
176 . ('1; foo' . CRLF . 'X' . CRLF) x 16 |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
177 . '0' . CRLF . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
178 ), |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
179 qr/ 200 /, 'chunk extensions' |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
180 ); |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
181 |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
182 like( |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
183 http( |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
184 'GET /large HTTP/1.1' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
185 . 'Host: localhost' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
186 . 'Connection: close' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
187 . 'Transfer-Encoding: chunked' . CRLF . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
188 . ('1; foo' . CRLF . 'X' . CRLF) x 512 |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
189 . '0' . CRLF . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
190 ), |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
191 qr/ 413 /, 'too many chunk extensions' |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
192 ); |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
193 |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
194 like( |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
195 http( |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
196 'GET /large HTTP/1.1' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
197 . 'Host: localhost' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
198 . 'Connection: close' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
199 . 'Transfer-Encoding: chunked' . CRLF . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
200 . '1' . CRLF . 'X' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
201 . '0' . CRLF . ('X-Trailer: foo' . CRLF) x 16 . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
202 ), |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
203 qr/ 200 /, 'trailers' |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
204 ); |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
205 |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
206 like( |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
207 http( |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
208 'GET /large HTTP/1.1' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
209 . 'Host: localhost' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
210 . 'Connection: close' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
211 . 'Transfer-Encoding: chunked' . CRLF . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
212 . '1' . CRLF . 'X' . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
213 . '0' . CRLF . ('X-Trailer: foo' . CRLF) x 512 . CRLF |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
214 ), |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
215 qr/ 413 /, 'too many trailers' |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
216 ); |
5cf0e07d63a1
Tests: tests for request body chunked extensions and trailers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
217 |
269
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
218 # proxy_next_upstream |
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
219 |
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
220 like(http_get_body('/next', '0123456789'), |
537
202de1d281e5
Tests: whitespace fixes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
317
diff
changeset
|
221 qr/X-Body: 0123456789\x0d?$/ms, 'body chunked next upstream'); |
269
970bb423e59f
Tests: proxy_next_upstream tests in body.t, body_chunked.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
222 |
1551
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
223 # invalid Transfer-Encoding |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
224 |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
225 like(http_transfer_encoding('identity'), qr/501 Not Implemented/, |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
226 'transfer encoding identity'); |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
227 |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
228 like(http_transfer_encoding("chunked\nTransfer-Encoding: chunked"), |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
229 qr/400 Bad/, 'transfer encoding repeat'); |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
230 |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
231 like(http_transfer_encoding('chunked, identity'), qr/501 Not Implemented/, |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
232 'transfer encoding list'); |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
233 |
1711
6c03c329ed95
Tests: requests with both Content-Length and Transfer-Encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
234 like(http_transfer_encoding("chunked\nContent-Length: 5"), qr/400 Bad/, |
6c03c329ed95
Tests: requests with both Content-Length and Transfer-Encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
235 'transfer encoding with content-length'); |
6c03c329ed95
Tests: requests with both Content-Length and Transfer-Encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
236 |
1722
122002b19416
Tests: HTTP/1.0 requests with Transfer-Encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1711
diff
changeset
|
237 like(http_transfer_encoding("chunked", "1.0"), qr/400 Bad/, |
122002b19416
Tests: HTTP/1.0 requests with Transfer-Encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1711
diff
changeset
|
238 'transfer encoding in HTTP/1.0 requests'); |
122002b19416
Tests: HTTP/1.0 requests with Transfer-Encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1711
diff
changeset
|
239 |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
240 ############################################################################### |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
241 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
242 sub read_body_file { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
243 my ($r) = @_; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
244 return '' unless $r =~ m/X-Body-File: (.*)/; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
245 open FILE, $1 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
246 or return "$!"; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
247 local $/; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
248 my $content = <FILE>; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
249 close FILE; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
250 return $content; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
251 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
252 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
253 sub http_get_body { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
254 my $uri = shift; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
255 my $last = pop; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
256 return http( join '', (map { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
257 my $body = $_; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
258 "GET $uri HTTP/1.1" . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
259 . "Host: localhost" . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
260 . "Transfer-Encoding: chunked" . CRLF . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
261 . sprintf("%x", length $body) . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
262 . $body . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
263 . "0" . CRLF . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
264 } @_), |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
265 "GET $uri HTTP/1.1" . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
266 . "Host: localhost" . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
267 . "Connection: close" . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
268 . "Transfer-Encoding: chunked" . CRLF . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
269 . sprintf("%x", length $last) . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
270 . $last . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
271 . "0" . CRLF . CRLF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
272 ); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
273 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
274 |
1551
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
275 sub http_transfer_encoding { |
1722
122002b19416
Tests: HTTP/1.0 requests with Transfer-Encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1711
diff
changeset
|
276 my ($encoding, $version) = @_; |
122002b19416
Tests: HTTP/1.0 requests with Transfer-Encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1711
diff
changeset
|
277 $version ||= "1.1"; |
1551
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
278 |
1722
122002b19416
Tests: HTTP/1.0 requests with Transfer-Encoding.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1711
diff
changeset
|
279 http("GET / HTTP/$version" . CRLF |
1551
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
280 . "Host: localhost" . CRLF |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
281 . "Connection: close" . CRLF |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
282 . "Transfer-Encoding: $encoding" . CRLF . CRLF |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
283 . "0" . CRLF . CRLF); |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
284 } |
27237569776f
Tests: additional Transfer-Encoding and Host headers tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1502
diff
changeset
|
285 |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
286 ############################################################################### |