Mercurial > hg > nginx-tests
annotate range_flv.t @ 1248:70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
The stream js tests introduced in edf5a3c9e36a fail on njs 0.1.14. It doesn't
currently provide an easy way to check its version, whilst we are obligated to
gracefully handle such cases somehow. With such an addition of 'require', now
the tests are skipped instead on the previous versions.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 21 Nov 2017 13:16:39 +0300 |
parents | 882267679006 |
children |
rev | line source |
---|---|
33 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for range filter module. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
121
8ac1faaddd2c
Tests: better handle various configure arguments.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http flv/)->plan(12); |
33 | 25 |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
28 %%TEST_GLOBALS%% |
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
29 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
166
diff
changeset
|
30 daemon off; |
33 | 31 |
32 events { | |
33 } | |
34 | |
35 http { | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
35
7bf0e8a1d66c
Tests: always define temp paths.
Maxim Dounin <mdounin@mdounin.ru>
parents:
33
diff
changeset
|
37 |
33 | 38 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
39 listen 127.0.0.1:8080; |
33 | 40 server_name localhost; |
41 location / { | |
42 flv; | |
43 } | |
44 } | |
45 } | |
46 | |
47 EOF | |
48 | |
49 $t->write_file('t1.flv', | |
50 join('', map { sprintf "X%03dXXXXXX", $_ } (0 .. 99))); | |
51 $t->run(); | |
52 | |
53 ############################################################################### | |
54 | |
55 my $t1; | |
56 | |
57 # FLV has 13 byte header at start. | |
58 | |
59 $t1 = http_get_range('/t1.flv?start=100', 'Range: bytes=0-9'); | |
491
d5bf5942a8b2
Tests: disambiguated parsing of the status code.
Sergey Kandaurov <pluknet@nginx.com>
parents:
249
diff
changeset
|
60 like($t1, qr/ 206 /, 'first bytes - 206 partial reply'); |
33 | 61 like($t1, qr/Content-Length: 10/, 'first bytes - correct length'); |
62 like($t1, qr/Content-Range: bytes 0-9\/913/, 'first bytes - content range'); | |
63 like($t1, qr/^FLV.{7}$/m, 'first bytes - correct content'); | |
64 | |
65 $t1 = http_get_range('/t1.flv?start=100', 'Range: bytes=-10'); | |
491
d5bf5942a8b2
Tests: disambiguated parsing of the status code.
Sergey Kandaurov <pluknet@nginx.com>
parents:
249
diff
changeset
|
66 like($t1, qr/ 206 /, 'final bytes - 206 partial reply'); |
33 | 67 like($t1, qr/Content-Length: 10/, 'final bytes - content length'); |
68 like($t1, qr/Content-Range: bytes 903-912\/913/, | |
69 'final bytes - content range'); | |
70 like($t1, qr/^X099XXXXXX$/m, 'final bytes - correct content'); | |
71 | |
72 $t1 = http_get_range('/t1.flv?start=100', 'Range: bytes=0-99'); | |
491
d5bf5942a8b2
Tests: disambiguated parsing of the status code.
Sergey Kandaurov <pluknet@nginx.com>
parents:
249
diff
changeset
|
73 like($t1, qr/ 206 /, 'multi buffers - 206 partial reply'); |
33 | 74 like($t1, qr/Content-Length: 100/, 'multi buffers - content length'); |
75 like($t1, qr/Content-Range: bytes 0-99\/913/, 'multi buffers - content range'); | |
76 like($t1, qr/^FLV.{10}X010XXXXXX(X01[1-7]XXXXXX){7}X018XXX$/m, | |
77 'multi buffers - correct content'); | |
78 | |
79 ############################################################################### | |
80 | |
81 sub http_get_range { | |
82 my ($url, $extra) = @_; | |
83 return http(<<EOF); | |
84 GET $url HTTP/1.1 | |
85 Host: localhost | |
86 Connection: close | |
87 $extra | |
88 | |
89 EOF | |
90 } | |
91 | |
92 ############################################################################### |