Skip to content

Commit 1406a89

Browse files
committed
Tests: scgi tests for combining headers.
1 parent 8c0fa7d commit 1406a89

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

scgi.t

+35-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ select STDOUT; $| = 1;
2424
eval { require SCGI; };
2525
plan(skip_all => 'SCGI not installed') if $@;
2626

27-
my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(7)
27+
my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(10)
2828
->write_file_expand('nginx.conf', <<'EOF');
2929
3030
%%TEST_GLOBALS%%
@@ -81,6 +81,33 @@ like(http_get('/var?b=127.0.0.1:' . port(8081)), qr/SEE-THIS/,
8181
'scgi with variables');
8282
like(http_get('/var?b=u'), qr/SEE-THIS/, 'scgi with variables to upstream');
8383

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+
84111
###############################################################################
85112

86113
sub http_get_headers {
@@ -131,9 +158,16 @@ sub scgi_daemon {
131158

132159
$count++;
133160

161+
my $xfwd = $request->env->{HTTP_X_FORWARDED_FOR} || '';
162+
my $cookie = $request->env->{HTTP_COOKIE} || '';
163+
my $foo = $request->env->{HTTP_FOO} || '';
164+
134165
$request->connection()->print(<<EOF);
135166
Location: http://localhost/redirect
136167
Content-Type: text/html
168+
X-Forwarded-For: $xfwd
169+
X-Cookie: $cookie
170+
X-Foo: $foo
137171
138172
SEE-THIS
139173
$count

0 commit comments

Comments
 (0)