Skip to content

Commit 747add1

Browse files
committed
Tests: uwsgi tests for combining headers.
1 parent 1406a89 commit 747add1

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

uwsgi.t

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use Test::Nginx;
2121
select STDERR; $| = 1;
2222
select STDOUT; $| = 1;
2323

24-
my $t = Test::Nginx->new()->has(qw/http uwsgi/)->has_daemon('uwsgi')->plan(5)
24+
my $t = Test::Nginx->new()->has(qw/http uwsgi/)->has_daemon('uwsgi')->plan(8)
2525
->write_file_expand('nginx.conf', <<'EOF');
2626
2727
%%TEST_GLOBALS%%
@@ -60,7 +60,12 @@ EOF
6060
$t->write_file('uwsgi_test_app.py', <<END);
6161
6262
def application(env, start_response):
63-
start_response('200 OK', [('Content-Type','text/plain')])
63+
start_response('200 OK', [
64+
('Content-Type', 'text/plain'),
65+
('X-Forwarded-For', env.get('HTTP_X_FORWARDED_FOR', '')),
66+
('X-Cookie', env.get('HTTP_COOKIE', '')),
67+
('X-Foo', env.get('HTTP_FOO', ''))
68+
])
6469
return b"SEE-THIS"
6570
6671
END
@@ -97,6 +102,33 @@ like(http_get('/var?b=127.0.0.1:' . port(8081)), qr/SEE-THIS/,
97102
'uwsgi with variables');
98103
like(http_get('/var?b=u'), qr/SEE-THIS/, 'uwsgi with variables to upstream');
99104

105+
TODO: {
106+
local $TODO = 'not yet' unless $t->has_version('1.23.0');
107+
108+
my $r = http(<<EOF);
109+
GET / HTTP/1.0
110+
Host: localhost
111+
X-Forwarded-For: foo
112+
X-Forwarded-For: bar
113+
X-Forwarded-For: bazz
114+
Cookie: foo
115+
Cookie: bar
116+
Cookie: bazz
117+
Foo: foo
118+
Foo: bar
119+
Foo: bazz
120+
121+
EOF
122+
123+
like($r, qr/X-Forwarded-For: foo, bar, bazz/,
124+
'uwsgi with multiple X-Forwarded-For headers');
125+
like($r, qr/X-Cookie: foo; bar; bazz/,
126+
'uwsgi with multiple Cookie headers');
127+
like($r, qr/X-Foo: foo, bar, bazz/,
128+
'uwsgi with multiple unknown headers');
129+
130+
}
131+
100132
###############################################################################
101133

102134
sub http_get_headers {

0 commit comments

Comments
 (0)