Mercurial > hg > nginx-tests
changeset 1764:be3ada2e9d24
Tests: scgi tests for combining headers.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 30 May 2022 21:29:45 +0300 |
parents | b7d0e595e927 |
children | 1d7932bc2847 |
files | scgi.t |
diffstat | 1 files changed, 35 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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' unless $t->has_version('1.23.0'); + +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