Mercurial > hg > nginx-tests
comparison proxy_xar.t @ 495:eaf287a41f08
Tests: added X-Accel-Redirect test with named location.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 13 Nov 2014 13:32:48 +0300 |
parents | 847ea345becb |
children | 907e89fba9c3 |
comparison
equal
deleted
inserted
replaced
494:623863fcb1d1 | 495:eaf287a41f08 |
---|---|
19 ############################################################################### | 19 ############################################################################### |
20 | 20 |
21 select STDERR; $| = 1; | 21 select STDERR; $| = 1; |
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
24 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(14); | 24 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(15); |
25 | 25 |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | 26 $t->write_file_expand('nginx.conf', <<'EOF'); |
27 | 27 |
28 %%TEST_GLOBALS%% | 28 %%TEST_GLOBALS%% |
29 | 29 |
37 | 37 |
38 server { | 38 server { |
39 listen 127.0.0.1:8080; | 39 listen 127.0.0.1:8080; |
40 server_name localhost; | 40 server_name localhost; |
41 | 41 |
42 # catch safe and unhandled unsafe URIs | 42 # catch safe and unhandled unsafe URIs, |
43 # bypassed with redirect to named location | |
43 if ($upstream_http_x_accel_redirect) { | 44 if ($upstream_http_x_accel_redirect) { |
44 return 200 "xar: $upstream_http_x_accel_redirect uri: $uri"; | 45 return 200 "xar: $upstream_http_x_accel_redirect uri: $uri"; |
45 } | 46 } |
46 | 47 |
47 location /proxy { | 48 location /proxy { |
62 | 63 |
63 # others won't be | 64 # others won't be |
64 add_header Something other; | 65 add_header Something other; |
65 | 66 |
66 return 204; | 67 return 204; |
68 } | |
69 location @named { | |
70 return 200 "named xar: $upstream_http_x_accel_redirect uri: $uri"; | |
67 } | 71 } |
68 } | 72 } |
69 } | 73 } |
70 | 74 |
71 EOF | 75 EOF |
97 unlike(http_get('/proxy?xar=/foo/.%2e'), qr/200 OK/, | 101 unlike(http_get('/proxy?xar=/foo/.%2e'), qr/200 OK/, |
98 'X-Accel-Redirect unsafe unescaped'); | 102 'X-Accel-Redirect unsafe unescaped'); |
99 like(http_get('/proxy?xar=/foo%20bar'), qr/uri: \/foo bar/, | 103 like(http_get('/proxy?xar=/foo%20bar'), qr/uri: \/foo bar/, |
100 'X-Accel-Redirect unescaped'); | 104 'X-Accel-Redirect unescaped'); |
101 | 105 |
106 TODO: { | |
107 local $TODO = 'not yet' unless $t->has_version('1.7.8'); | |
108 | |
109 like(http_get('/proxy?xar=@named'), | |
110 qr!200 OK.*named xar: \@named uri: /proxy!s, 'in named location'); | |
111 | |
112 } | |
113 | |
102 ############################################################################### | 114 ############################################################################### |