Mercurial > hg > nginx-tests
comparison proxy-xar.t @ 82:a2fc9b9e9a2b
Tests: add X-Accel-Redirect tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 08 Apr 2009 03:45:14 +0400 |
parents | |
children | 1c0ec30614c6 |
comparison
equal
deleted
inserted
replaced
81:6d93f3a4ce48 | 82:a2fc9b9e9a2b |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for proxy X-Accel-Redirect functionality. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
24 my $t = Test::Nginx->new()->has('rewrite')->plan(8); | |
25 | |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
28 master_process off; | |
29 daemon off; | |
30 | |
31 events { | |
32 } | |
33 | |
34 http { | |
35 access_log off; | |
36 root %%TESTDIR%%; | |
37 | |
38 client_body_temp_path %%TESTDIR%%/client_body_temp; | |
39 fastcgi_temp_path %%TESTDIR%%/fastcgi_temp; | |
40 proxy_temp_path %%TESTDIR%%/proxy_temp; | |
41 | |
42 server { | |
43 listen 127.0.0.1:8080; | |
44 server_name localhost; | |
45 | |
46 location /proxy { | |
47 proxy_pass http://127.0.0.1:8080/return-xar; | |
48 } | |
49 location /return-xar { | |
50 add_header X-Accel-Redirect /index.html; | |
51 | |
52 # this headers will be preserved on | |
53 # X-Accel-Redirect | |
54 | |
55 add_header Content-Type text/blah; | |
56 add_header Set-Cookie blah=blah; | |
57 add_header Content-Disposition attachment; | |
58 add_header Cache-Control no-cache; | |
59 add_header Expires fake; | |
60 add_header Accept-Ranges parrots; | |
61 | |
62 # others won't be | |
63 add_header Something other; | |
64 | |
65 return 204; | |
66 } | |
67 } | |
68 } | |
69 | |
70 EOF | |
71 | |
72 $t->write_file('index.html', 'SEE-THIS'); | |
73 $t->run(); | |
74 | |
75 ############################################################################### | |
76 | |
77 my $r = http_get('/proxy'); | |
78 like($r, qr/SEE-THIS/, 'X-Accel-Redirect works'); | |
79 like($r, qr/^Content-Type: text\/blah/m, 'Content-Type preserved'); | |
80 like($r, qr/^Set-Cookie: blah=blah/m, 'Set-Cookie preserved'); | |
81 like($r, qr/^Content-Disposition: attachment/m, 'Content-Disposition preserved'); | |
82 like($r, qr/^Cache-Control: no-cache/m, 'Cache-Control preserved'); | |
83 like($r, qr/^Expires: fake/m, 'Expires preserved'); | |
84 like($r, qr/^Accept-Ranges: parrots/m, 'Accept-Ranges preserved'); | |
85 unlike($r, qr/^Something/m, 'other headers stripped'); | |
86 | |
87 ############################################################################### |