Skip to content

Commit 8c0fa7d

Browse files
committed
Tests: fastcgi tests for combining headers.
1 parent 3c50188 commit 8c0fa7d

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

fastcgi_header_params.t

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ eval { require FCGI; };
2525
plan(skip_all => 'FCGI not installed') if $@;
2626
plan(skip_all => 'win32') if $^O eq 'MSWin32';
2727

28-
my $t = Test::Nginx->new()->has(qw/http fastcgi/)->plan(1)
28+
my $t = Test::Nginx->new()->has(qw/http fastcgi/)->plan(4)
2929
->write_file_expand('nginx.conf', <<'EOF');
3030
3131
%%TEST_GLOBALS%%
@@ -59,6 +59,37 @@ $t->run()->waitforsocket('127.0.0.1:' . port(8081));
5959
like(http_get_headers('/'), qr/SEE-THIS/,
6060
'fastcgi request with many ignored headers');
6161

62+
TODO: {
63+
local $TODO = 'not yet' unless $t->has_version('1.23.0');
64+
65+
my $r;
66+
67+
$r = http(<<EOF);
68+
GET / HTTP/1.0
69+
Host: localhost
70+
X-Forwarded-For: foo
71+
X-Forwarded-For: bar
72+
X-Forwarded-For: bazz
73+
Cookie: foo
74+
Cookie: bar
75+
Cookie: bazz
76+
Foo: foo
77+
Foo: bar
78+
Foo: bazz
79+
80+
EOF
81+
82+
like($r, qr/X-Forwarded-For: foo, bar, bazz/,
83+
'fastcgi with multiple X-Forwarded-For headers');
84+
85+
like($r, qr/X-Cookie: foo; bar; bazz/,
86+
'fastcgi with multiple Cookie headers');
87+
88+
like($r, qr/X-Foo: foo, bar, bazz/,
89+
'fastcgi with multiple unknown headers');
90+
91+
}
92+
6293
###############################################################################
6394

6495
sub http_get_headers {
@@ -100,9 +131,16 @@ sub fastcgi_daemon {
100131
while( $request->Accept() >= 0 ) {
101132
$count++;
102133

134+
my $xfwd = $ENV{HTTP_X_FORWARDED_FOR} || '';
135+
my $cookie = $ENV{HTTP_COOKIE} || '';
136+
my $foo = $ENV{HTTP_FOO} || '';
137+
103138
print <<EOF;
104139
Location: http://localhost/redirect
105140
Content-Type: text/html
141+
X-Forwarded-For: $xfwd
142+
X-Cookie: $cookie
143+
X-Foo: $foo
106144
107145
SEE-THIS
108146
$count

0 commit comments

Comments
 (0)