Mercurial > hg > nginx-tests
annotate dav_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 |
---|---|
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 dav module with chunked request body. |
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 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http dav/)->plan(6); |
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 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
40 listen 127.0.0.1:8080; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 server_name localhost; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 client_header_buffer_size 1k; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 client_body_buffer_size 2k; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 location / { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 dav_methods PUT; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 } |
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 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 EOF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 $t->run(); |
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 ############################################################################### |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 my $r; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 $r = http(<<EOF); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 PUT /file HTTP/1.1 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 Host: localhost |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 Connection: close |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 Transfer-Encoding: chunked |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 a |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 1234567890 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 0 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 EOF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'put chunked'); |
467
43e05ac6c23c
Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents:
339
diff
changeset
|
73 is($t->read_file('file'), '1234567890', 'put content'); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 $r = http(<<EOF); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 PUT /file HTTP/1.1 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 Host: localhost |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 Connection: close |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 Transfer-Encoding: chunked |
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 0 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 EOF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 like($r, qr/204 No Content/, 'put chunked empty'); |
467
43e05ac6c23c
Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents:
339
diff
changeset
|
86 is($t->read_file('file'), '', 'put empty content'); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 my $body = ('a' . CRLF . '1234567890' . CRLF) x 1024 . '0' . CRLF . CRLF; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 |
339
9d0a2fa47ac6
Tests: change http timeout to 5s, imap/pop3/smtp to 3s.
Maxim Dounin <mdounin@mdounin.ru>
parents:
317
diff
changeset
|
90 $r = http(<<EOF); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 PUT /file HTTP/1.1 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 Host: localhost |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 Connection: close |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 Transfer-Encoding: chunked |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 $body |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 EOF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 like($r, qr/204 No Content/, 'put chunked big'); |
467
43e05ac6c23c
Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents:
339
diff
changeset
|
100 is($t->read_file('file'), '1234567890' x 1024, 'put big content'); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 ############################################################################### |