[PATCH 04 of 10] Tests: uwsgi tests for combining headers

Maxim Dounin mdounin at mdounin.ru
Wed Apr 20 22:37:45 UTC 2022


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1650492931 -10800
#      Thu Apr 21 01:15:31 2022 +0300
# Node ID 7769bbed69deebfb59b9f312b67788ab75d454c7
# Parent  0a795402009e9aaff1d2c58c7417d574e848ee43
Tests: uwsgi tests for combining headers.

diff --git a/uwsgi.t b/uwsgi.t
--- a/uwsgi.t
+++ b/uwsgi.t
@@ -21,7 +21,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http uwsgi/)->has_daemon('uwsgi')->plan(5)
+my $t = Test::Nginx->new()->has(qw/http uwsgi/)->has_daemon('uwsgi')->plan(8)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -60,7 +60,12 @@ EOF
 $t->write_file('uwsgi_test_app.py', <<END);
 
 def application(env, start_response):
-    start_response('200 OK', [('Content-Type','text/plain')])
+    start_response('200 OK', [
+       ('Content-Type', 'text/plain'),
+       ('X-Forwarded-For', env.get('HTTP_X_FORWARDED_FOR', '')),
+       ('X-Cookie', env.get('HTTP_COOKIE', '')),
+       ('X-Foo', env.get('HTTP_FOO', ''))
+    ])
     return b"SEE-THIS"
 
 END
@@ -97,6 +102,33 @@ like(http_get('/var?b=127.0.0.1:' . port
 	'uwsgi with variables');
 like(http_get('/var?b=u'), qr/SEE-THIS/, 'uwsgi with variables to upstream');
 
+TODO: {
+local $TODO = 'not yet';
+
+my $r = http(<<EOF);
+GET / HTTP/1.0
+Host: localhost
+X-Forwarded-For: foo
+X-Forwarded-For: bar
+X-Forwarded-For: bazz
+Cookie: foo
+Cookie: bar
+Cookie: bazz
+Foo: foo
+Foo: bar
+Foo: bazz
+
+EOF
+
+like($r, qr/X-Forwarded-For: foo, bar, bazz/,
+	'uwsgi with multiple X-Forwarded-For headers');
+like($r, qr/X-Cookie: foo; bar; bazz/,
+	'uwsgi with multiple Cookie headers');
+like($r, qr/X-Foo: foo, bar, bazz/,
+	'uwsgi with multiple unknown headers');
+
+}
+
 ###############################################################################
 
 sub http_get_headers {



More information about the nginx-devel mailing list