Mercurial > hg > nginx-tests
comparison sub_filter_slice.t @ 1056:1e41a0de0772
Tests: various last_buf tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 12 Oct 2016 17:49:03 +0300 |
parents | |
children | 766bcbb632ee |
comparison
equal
deleted
inserted
replaced
1055:8979f0d86c29 | 1056:1e41a0de0772 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for slice filter with sub filter. | |
7 | |
8 # A response is sent using chunked encoding. | |
9 | |
10 ############################################################################### | |
11 | |
12 use warnings; | |
13 use strict; | |
14 | |
15 use Test::More; | |
16 | |
17 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
18 | |
19 use lib 'lib'; | |
20 use Test::Nginx; | |
21 | |
22 ############################################################################### | |
23 | |
24 select STDERR; $| = 1; | |
25 select STDOUT; $| = 1; | |
26 | |
27 my $t = Test::Nginx->new()->has(qw/http proxy slice sub/)->plan(3); | |
28 | |
29 $t->write_file_expand('nginx.conf', <<'EOF'); | |
30 | |
31 %%TEST_GLOBALS%% | |
32 | |
33 daemon off; | |
34 | |
35 events { | |
36 } | |
37 | |
38 http { | |
39 %%TEST_GLOBALS_HTTP%% | |
40 | |
41 server { | |
42 listen 127.0.0.1:8080; | |
43 server_name localhost; | |
44 | |
45 location / { | |
46 sub_filter foo bar; | |
47 sub_filter_types *; | |
48 | |
49 slice 2; | |
50 | |
51 proxy_pass http://127.0.0.1:8081/; | |
52 | |
53 proxy_set_header Range $slice_range; | |
54 } | |
55 } | |
56 | |
57 server { | |
58 listen 127.0.0.1:8081; | |
59 server_name localhost; | |
60 | |
61 location / { } | |
62 } | |
63 } | |
64 | |
65 EOF | |
66 | |
67 $t->write_file('t', '0123456789'); | |
68 $t->run(); | |
69 | |
70 ############################################################################### | |
71 | |
72 my $r; | |
73 | |
74 TODO: { | |
75 local $TODO = 'not yet' unless $t->has_version('1.11.5'); | |
76 | |
77 # range filter in subrequests (subrequest_ranges) | |
78 | |
79 $r = get('/t', 'Range: bytes=2-4'); | |
80 unlike($r, qr/\x0d\x0a?0\x0d\x0a?\x0d\x0a?\w/, 'only final chunk'); | |
81 | |
82 } | |
83 | |
84 TODO: { | |
85 local $TODO = 'not yet'; | |
86 | |
87 # server is assumed to return the requested range | |
88 | |
89 $r = get('/t', 'Range: bytes=3-4'); | |
90 like($r, qr/ 206 /, 'range request - 206 partial reply'); | |
91 is(Test::Nginx::http_content($r), '34', 'range request - correct content'); | |
92 | |
93 } | |
94 | |
95 ############################################################################### | |
96 | |
97 sub get { | |
98 my ($url, $extra) = @_; | |
99 return http(<<EOF); | |
100 GET $url HTTP/1.1 | |
101 Host: localhost | |
102 Connection: close | |
103 $extra | |
104 | |
105 EOF | |
106 } | |
107 | |
108 ############################################################################### |