changeset 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 623863fcb1d1
children d13ea470657d
files proxy_xar.t
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/proxy_xar.t
+++ b/proxy_xar.t
@@ -21,7 +21,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(14);
+my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(15);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -39,7 +39,8 @@ http {
         listen       127.0.0.1:8080;
         server_name  localhost;
 
-        # catch safe and unhandled unsafe URIs
+        # catch safe and unhandled unsafe URIs,
+        # bypassed with redirect to named location
         if ($upstream_http_x_accel_redirect) {
             return 200 "xar: $upstream_http_x_accel_redirect uri: $uri";
         }
@@ -65,6 +66,9 @@ http {
 
             return 204;
         }
+        location @named {
+            return 200 "named xar: $upstream_http_x_accel_redirect uri: $uri";
+        }
     }
 }
 
@@ -99,4 +103,12 @@ unlike(http_get('/proxy?xar=/foo/.%2e'),
 like(http_get('/proxy?xar=/foo%20bar'), qr/uri: \/foo bar/,
 	'X-Accel-Redirect unescaped');
 
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.7.8');
+
+like(http_get('/proxy?xar=@named'),
+	qr!200 OK.*named xar: \@named uri: /proxy!s, 'in named location');
+
+}
+
 ###############################################################################