Mercurial > hg > nginx-tests
changeset 1765:1d7932bc2847
Tests: uwsgi tests for combining headers.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 30 May 2022 21:30:35 +0300 |
parents | be3ada2e9d24 |
children | a2572de6e840 |
files | uwsgi.t |
diffstat | 1 files changed, 34 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/uwsgi.t Mon May 30 21:29:45 2022 +0300 +++ b/uwsgi.t Mon May 30 21:30:35 2022 +0300 @@ -21,7 +21,7 @@ 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 @@ $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 @@ 'uwsgi with variables'); like(http_get('/var?b=u'), qr/SEE-THIS/, 'uwsgi 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/, + '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 {