[PATCH 03 of 10] Tests: scgi tests for combining headers

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


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1650492930 -10800
#      Thu Apr 21 01:15:30 2022 +0300
# Node ID 0a795402009e9aaff1d2c58c7417d574e848ee43
# Parent  910b323534f0100d0a1c8c7934a0e91c51f4e888
Tests: scgi tests for combining headers.

diff --git a/scgi.t b/scgi.t
--- a/scgi.t
+++ b/scgi.t
@@ -24,7 +24,7 @@ select STDOUT; $| = 1;
 eval { require SCGI; };
 plan(skip_all => 'SCGI not installed') if $@;
 
-my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(7)
+my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(10)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -81,6 +81,33 @@ like(http_get('/var?b=127.0.0.1:' . port
 	'scgi with variables');
 like(http_get('/var?b=u'), qr/SEE-THIS/, 'scgi 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/,
+	'scgi with multiple X-Forwarded-For headers');
+like($r, qr/X-Cookie: foo; bar; bazz/,
+	'scgi with multiple Cookie headers');
+like($r, qr/X-Foo: foo, bar, bazz/,
+	'scgi with multiple unknown headers');
+
+}
+
 ###############################################################################
 
 sub http_get_headers {
@@ -131,9 +158,16 @@ sub scgi_daemon {
 
 		$count++;
 
+		my $xfwd = $request->env->{HTTP_X_FORWARDED_FOR} || '';
+		my $cookie = $request->env->{HTTP_COOKIE} || '';
+		my $foo = $request->env->{HTTP_FOO} || '';
+
 		$request->connection()->print(<<EOF);
 Location: http://localhost/redirect
 Content-Type: text/html
+X-Forwarded-For: $xfwd
+X-Cookie: $cookie
+X-Foo: $foo
 
 SEE-THIS
 $count



More information about the nginx-devel mailing list