Mercurial > hg > nginx-tests
comparison proxy_xar.t @ 148:b714d6df958c
Tests: rename some tests for better sorting.
Use underscore instead of dash. Addtionally, rename some tests to better
match "module" + "details" scheme used: use "http_" prefix for http core
module tests, use "mail_" prefix for mail module tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 04 Mar 2011 16:07:15 +0300 |
parents | proxy-xar.t@8ac1faaddd2c |
children | c0ae29632905 |
comparison
equal
deleted
inserted
replaced
147:fd865ada95c8 | 148:b714d6df958c |
---|---|
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(qw/http proxy rewrite/)->plan(8); | |
25 | |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
30 master_process off; | |
31 daemon off; | |
32 | |
33 events { | |
34 } | |
35 | |
36 http { | |
37 %%TEST_GLOBALS_HTTP%% | |
38 | |
39 server { | |
40 listen 127.0.0.1:8080; | |
41 server_name localhost; | |
42 | |
43 location /proxy { | |
44 proxy_pass http://127.0.0.1:8080/return-xar; | |
45 } | |
46 location /return-xar { | |
47 add_header X-Accel-Redirect /index.html; | |
48 | |
49 # this headers will be preserved on | |
50 # X-Accel-Redirect | |
51 | |
52 add_header Content-Type text/blah; | |
53 add_header Set-Cookie blah=blah; | |
54 add_header Content-Disposition attachment; | |
55 add_header Cache-Control no-cache; | |
56 add_header Expires fake; | |
57 add_header Accept-Ranges parrots; | |
58 | |
59 # others won't be | |
60 add_header Something other; | |
61 | |
62 return 204; | |
63 } | |
64 } | |
65 } | |
66 | |
67 EOF | |
68 | |
69 $t->write_file('index.html', 'SEE-THIS'); | |
70 $t->run(); | |
71 | |
72 ############################################################################### | |
73 | |
74 my $r = http_get('/proxy'); | |
75 like($r, qr/SEE-THIS/, 'X-Accel-Redirect works'); | |
76 like($r, qr/^Content-Type: text\/blah/m, 'Content-Type preserved'); | |
77 like($r, qr/^Set-Cookie: blah=blah/m, 'Set-Cookie preserved'); | |
78 like($r, qr/^Content-Disposition: attachment/m, 'Content-Disposition preserved'); | |
79 like($r, qr/^Cache-Control: no-cache/m, 'Cache-Control preserved'); | |
80 like($r, qr/^Expires: fake/m, 'Expires preserved'); | |
81 like($r, qr/^Accept-Ranges: parrots/m, 'Accept-Ranges preserved'); | |
82 unlike($r, qr/^Something/m, 'other headers stripped'); | |
83 | |
84 ############################################################################### |