Mercurial > hg > nginx-tests
comparison dav_chunked.t @ 467:43e05ac6c23c
Tests: the read_file function added in Test::Nginx.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 22 Sep 2014 13:30:04 +0400 |
parents | 9d0a2fa47ac6 |
children | e9064d691790 |
comparison
equal
deleted
inserted
replaced
466:a64b4057189c | 467:43e05ac6c23c |
---|---|
68 0 | 68 0 |
69 | 69 |
70 EOF | 70 EOF |
71 | 71 |
72 like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'put chunked'); | 72 like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'put chunked'); |
73 is(read_file($t->testdir() . '/file'), '1234567890', 'put content'); | 73 is($t->read_file('file'), '1234567890', 'put content'); |
74 | 74 |
75 $r = http(<<EOF); | 75 $r = http(<<EOF); |
76 PUT /file HTTP/1.1 | 76 PUT /file HTTP/1.1 |
77 Host: localhost | 77 Host: localhost |
78 Connection: close | 78 Connection: close |
81 0 | 81 0 |
82 | 82 |
83 EOF | 83 EOF |
84 | 84 |
85 like($r, qr/204 No Content/, 'put chunked empty'); | 85 like($r, qr/204 No Content/, 'put chunked empty'); |
86 is(read_file($t->testdir() . '/file'), '', 'put empty content'); | 86 is($t->read_file('file'), '', 'put empty content'); |
87 | 87 |
88 my $body = ('a' . CRLF . '1234567890' . CRLF) x 1024 . '0' . CRLF . CRLF; | 88 my $body = ('a' . CRLF . '1234567890' . CRLF) x 1024 . '0' . CRLF . CRLF; |
89 | 89 |
90 $r = http(<<EOF); | 90 $r = http(<<EOF); |
91 PUT /file HTTP/1.1 | 91 PUT /file HTTP/1.1 |
95 | 95 |
96 $body | 96 $body |
97 EOF | 97 EOF |
98 | 98 |
99 like($r, qr/204 No Content/, 'put chunked big'); | 99 like($r, qr/204 No Content/, 'put chunked big'); |
100 is(read_file($t->testdir() . '/file'), '1234567890' x 1024, 'put big content'); | 100 is($t->read_file('file'), '1234567890' x 1024, 'put big content'); |
101 | 101 |
102 ############################################################################### | 102 ############################################################################### |
103 | |
104 sub read_file { | |
105 my ($file) = @_; | |
106 open FILE, $file | |
107 or return "$!"; | |
108 local $/; | |
109 my $content = <FILE>; | |
110 close FILE; | |
111 return $content; | |
112 } | |
113 | |
114 ############################################################################### |