Mercurial > hg > nginx-tests
comparison proxy_set_body.t @ 283:36d24870ccb2
Tests: proxy_set_body tests added.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 11 May 2013 20:09:31 +0400 |
parents | |
children | f62137d1b5b1 |
comparison
equal
deleted
inserted
replaced
282:04832fc79805 | 283:36d24870ccb2 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for proxy_set_body. | |
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(2) | |
25 ->write_file_expand('nginx.conf', <<'EOF'); | |
26 | |
27 %%TEST_GLOBALS%% | |
28 | |
29 daemon off; | |
30 | |
31 events { | |
32 } | |
33 | |
34 http { | |
35 %%TEST_GLOBALS_HTTP%% | |
36 | |
37 server { | |
38 listen 127.0.0.1:8080; | |
39 server_name localhost; | |
40 | |
41 location / { | |
42 proxy_pass http://127.0.0.1:8080/body; | |
43 proxy_set_body "body"; | |
44 } | |
45 | |
46 location /p1 { | |
47 proxy_pass http://127.0.0.1:8080/x1; | |
48 proxy_set_body "body"; | |
49 } | |
50 | |
51 location /p2 { | |
52 proxy_pass http://127.0.0.1:8080/body; | |
53 proxy_set_body "body two"; | |
54 } | |
55 | |
56 location /x1 { | |
57 add_header X-Accel-Redirect /p2; | |
58 return 204; | |
59 } | |
60 | |
61 location /body { | |
62 add_header X-Body $request_body; | |
63 proxy_pass http://127.0.0.1:8080/empty; | |
64 } | |
65 | |
66 location /empty { | |
67 return 204; | |
68 } | |
69 } | |
70 } | |
71 | |
72 EOF | |
73 | |
74 $t->run(); | |
75 | |
76 ############################################################################### | |
77 | |
78 like(http_get('/'), qr/X-Body: body/, 'proxy_set_body'); | |
79 | |
80 TODO: { | |
81 local $TODO = 'not yet'; | |
82 | |
83 like(http_get('/p1'), qr/X-Body: body two/, 'proxy_set_body twice'); | |
84 | |
85 } | |
86 | |
87 ############################################################################### |