comparison proxy_xar.t @ 923:9239393e73c8

Tests: added X-Accel-Redirect test for request method name change.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 12 May 2016 14:07:10 +0300
parents 907e89fba9c3
children e9064d691790
comparison
equal deleted inserted replaced
922:93d900bac201 923:9239393e73c8
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(15); 24 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(16);
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
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 # bypassed with redirect to named location
44 if ($upstream_http_x_accel_redirect) { 44 if ($upstream_http_x_accel_redirect) {
45 return 200 "xar: $upstream_http_x_accel_redirect uri: $uri"; 45 return 200 "xar: $upstream_http_x_accel_redirect uri: $uri
46 method: $request_method";
46 } 47 }
47 48
48 location /proxy { 49 location /proxy {
49 proxy_pass http://127.0.0.1:8080/return-xar; 50 proxy_pass http://127.0.0.1:8080/return-xar;
50 } 51 }
86 like($r, qr/^Cache-Control: no-cache/m, 'Cache-Control preserved'); 87 like($r, qr/^Cache-Control: no-cache/m, 'Cache-Control preserved');
87 like($r, qr/^Expires: fake/m, 'Expires preserved'); 88 like($r, qr/^Expires: fake/m, 'Expires preserved');
88 like($r, qr/^Accept-Ranges: parrots/m, 'Accept-Ranges preserved'); 89 like($r, qr/^Accept-Ranges: parrots/m, 'Accept-Ranges preserved');
89 unlike($r, qr/^Something/m, 'other headers stripped'); 90 unlike($r, qr/^Something/m, 'other headers stripped');
90 91
92 like(http_post('/proxy?xar=/index.html'), qr/method: GET/,
93 'X-Accel-Redirect method name');
94
91 # escaped characters 95 # escaped characters
92 96
93 like(http_get('/proxy?xar=/foo?bar'), qr/200 OK.*xar: \/foo\?bar/s, 97 like(http_get('/proxy?xar=/foo?bar'), qr/200 OK.*xar: \/foo\?bar/s,
94 'X-Accel-Redirect value unchanged'); 98 'X-Accel-Redirect value unchanged');
95 unlike(http_get('/proxy?xar=..'), qr/200 OK/, 99 unlike(http_get('/proxy?xar=..'), qr/200 OK/,
105 109
106 like(http_get('/proxy?xar=@named'), 110 like(http_get('/proxy?xar=@named'),
107 qr!200 OK.*named xar: \@named uri: /proxy!s, 'in named location'); 111 qr!200 OK.*named xar: \@named uri: /proxy!s, 'in named location');
108 112
109 ############################################################################### 113 ###############################################################################
114
115 sub http_post {
116 my ($url) = @_;
117 http(<<EOF);
118 POST $url HTTP/1.0
119 Host: localhost
120
121 EOF
122 }
123
124 ###############################################################################