-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathsub_filter_slice.t
More file actions
103 lines (66 loc) · 1.91 KB
/
sub_filter_slice.t
File metadata and controls
103 lines (66 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/perl
# (C) Sergey Kandaurov
# (C) Nginx, Inc.
# Tests for slice filter with sub filter.
# A response is sent using chunked encoding.
###############################################################################
use warnings;
use strict;
use Test::More;
BEGIN { use FindBin; chdir($FindBin::Bin); }
use lib 'lib';
use Test::Nginx qw/ :DEFAULT http_content /;
###############################################################################
select STDERR; $| = 1;
select STDOUT; $| = 1;
my $t = Test::Nginx->new()->has(qw/http proxy slice sub/)->plan(3);
$t->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
daemon off;
events {
}
http {
%%TEST_GLOBALS_HTTP%%
server {
listen 127.0.0.1:8080;
server_name localhost;
location / {
sub_filter foo bar;
sub_filter_types *;
slice 2;
proxy_pass http://127.0.0.1:8081/;
proxy_set_header Range $slice_range;
}
}
server {
listen 127.0.0.1:8081;
server_name localhost;
location / { }
}
}
EOF
$t->write_file('t', '0123456789');
$t->run();
###############################################################################
my $r;
# range filter in subrequests (subrequest_ranges)
$r = get('/t', 'Range: bytes=2-4');
unlike($r, qr/\x0d\x0a?0\x0d\x0a?\x0d\x0a?\w/, 'only final chunk');
TODO: {
local $TODO = 'not yet';
# server is assumed to return the requested range
$r = get('/t', 'Range: bytes=3-4');
like($r, qr/ 206 /, 'range request - 206 partial reply');
is(http_content($r), '34', 'range request - correct content');
}
###############################################################################
sub get {
my ($url, $extra) = @_;
return http(<<EOF);
GET $url HTTP/1.1
Host: localhost
Connection: close
$extra
EOF
}
###############################################################################