Mercurial > hg > nginx-tests
comparison scgi.t @ 1764:be3ada2e9d24
Tests: scgi tests for combining headers.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 30 May 2022 21:29:45 +0300 |
parents | 882267679006 |
children |
comparison
equal
deleted
inserted
replaced
1763:b7d0e595e927 | 1764:be3ada2e9d24 |
---|---|
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
24 eval { require SCGI; }; | 24 eval { require SCGI; }; |
25 plan(skip_all => 'SCGI not installed') if $@; | 25 plan(skip_all => 'SCGI not installed') if $@; |
26 | 26 |
27 my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(7) | 27 my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(10) |
28 ->write_file_expand('nginx.conf', <<'EOF'); | 28 ->write_file_expand('nginx.conf', <<'EOF'); |
29 | 29 |
30 %%TEST_GLOBALS%% | 30 %%TEST_GLOBALS%% |
31 | 31 |
32 daemon off; | 32 daemon off; |
79 | 79 |
80 like(http_get('/var?b=127.0.0.1:' . port(8081)), qr/SEE-THIS/, | 80 like(http_get('/var?b=127.0.0.1:' . port(8081)), qr/SEE-THIS/, |
81 'scgi with variables'); | 81 'scgi with variables'); |
82 like(http_get('/var?b=u'), qr/SEE-THIS/, 'scgi with variables to upstream'); | 82 like(http_get('/var?b=u'), qr/SEE-THIS/, 'scgi with variables to upstream'); |
83 | 83 |
84 TODO: { | |
85 local $TODO = 'not yet' unless $t->has_version('1.23.0'); | |
86 | |
87 my $r = http(<<EOF); | |
88 GET / HTTP/1.0 | |
89 Host: localhost | |
90 X-Forwarded-For: foo | |
91 X-Forwarded-For: bar | |
92 X-Forwarded-For: bazz | |
93 Cookie: foo | |
94 Cookie: bar | |
95 Cookie: bazz | |
96 Foo: foo | |
97 Foo: bar | |
98 Foo: bazz | |
99 | |
100 EOF | |
101 | |
102 like($r, qr/X-Forwarded-For: foo, bar, bazz/, | |
103 'scgi with multiple X-Forwarded-For headers'); | |
104 like($r, qr/X-Cookie: foo; bar; bazz/, | |
105 'scgi with multiple Cookie headers'); | |
106 like($r, qr/X-Foo: foo, bar, bazz/, | |
107 'scgi with multiple unknown headers'); | |
108 | |
109 } | |
110 | |
84 ############################################################################### | 111 ############################################################################### |
85 | 112 |
86 sub http_get_headers { | 113 sub http_get_headers { |
87 my ($url, %extra) = @_; | 114 my ($url, %extra) = @_; |
88 return http(<<EOF, %extra); | 115 return http(<<EOF, %extra); |
129 eval { $request->read_env(); }; | 156 eval { $request->read_env(); }; |
130 next if $@; | 157 next if $@; |
131 | 158 |
132 $count++; | 159 $count++; |
133 | 160 |
161 my $xfwd = $request->env->{HTTP_X_FORWARDED_FOR} || ''; | |
162 my $cookie = $request->env->{HTTP_COOKIE} || ''; | |
163 my $foo = $request->env->{HTTP_FOO} || ''; | |
164 | |
134 $request->connection()->print(<<EOF); | 165 $request->connection()->print(<<EOF); |
135 Location: http://localhost/redirect | 166 Location: http://localhost/redirect |
136 Content-Type: text/html | 167 Content-Type: text/html |
168 X-Forwarded-For: $xfwd | |
169 X-Cookie: $cookie | |
170 X-Foo: $foo | |
137 | 171 |
138 SEE-THIS | 172 SEE-THIS |
139 $count | 173 $count |
140 EOF | 174 EOF |
141 } | 175 } |