comparison body.t @ 269:970bb423e59f

Tests: proxy_next_upstream tests in body.t, body_chunked.t.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 12 Mar 2013 20:07:25 +0400
parents 9f0ed4d54ae3
children 1a6eef7ac914
comparison
equal deleted inserted replaced
268:8dac281ff522 269:970bb423e59f
20 ############################################################################### 20 ###############################################################################
21 21
22 select STDERR; $| = 1; 22 select STDERR; $| = 1;
23 select STDOUT; $| = 1; 23 select STDOUT; $| = 1;
24 24
25 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(11); 25 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(12);
26 26
27 $t->write_file_expand('nginx.conf', <<'EOF'); 27 $t->write_file_expand('nginx.conf', <<'EOF');
28 28
29 %%TEST_GLOBALS%% 29 %%TEST_GLOBALS%%
30 30
33 events { 33 events {
34 } 34 }
35 35
36 http { 36 http {
37 %%TEST_GLOBALS_HTTP%% 37 %%TEST_GLOBALS_HTTP%%
38
39 upstream u {
40 server 127.0.0.1:8082;
41 server 127.0.0.1:8080 backup;
42 }
38 43
39 server { 44 server {
40 listen 127.0.0.1:8080; 45 listen 127.0.0.1:8080;
41 server_name localhost; 46 server_name localhost;
42 47
66 proxy_pass http://127.0.0.1:8081; 71 proxy_pass http://127.0.0.1:8081;
67 } 72 }
68 location /discard { 73 location /discard {
69 return 200 "TEST\n"; 74 return 200 "TEST\n";
70 } 75 }
76 location /next {
77 proxy_pass http://u/;
78 }
71 } 79 }
72 80
73 server { 81 server {
74 listen 127.0.0.1:8081; 82 listen 127.0.0.1:8081;
75 server_name localhost; 83 server_name localhost;
76 84
77 location / { 85 location / {
78 return 200 "TEST\n"; 86 return 200 "TEST\n";
87 }
88 }
89
90 server {
91 listen 127.0.0.1:8082;
92 server_name localhost;
93
94 location / {
95 return 444;
79 } 96 }
80 } 97 }
81 } 98 }
82 99
83 EOF 100 EOF
120 # proxy with file only 137 # proxy with file only
121 138
122 like(http_get_body('/small', '0123456789'), 139 like(http_get_body('/small', '0123456789'),
123 qr/X-Body: 0123456789\x0d?$/ms, 'small body in file only'); 140 qr/X-Body: 0123456789\x0d?$/ms, 'small body in file only');
124 141
142 # proxy_next_upstream
143
144 like(http_get_body('/next', '0123456789'),
145 qr/X-Body: 0123456789\x0d?$/ms, 'body next upstream');
146
125 ############################################################################### 147 ###############################################################################
126 148
127 sub read_body_file { 149 sub read_body_file {
128 my ($r) = @_; 150 my ($r) = @_;
129 return '' unless $r =~ m/X-Body-File: (.*)/; 151 return '' unless $r =~ m/X-Body-File: (.*)/;