Mercurial > hg > nginx-tests
comparison uwsgi.t @ 1765:1d7932bc2847
Tests: uwsgi tests for combining headers.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 30 May 2022 21:30:35 +0300 |
parents | f069dd7ba5a7 |
children | a095b971fbcc |
comparison
equal
deleted
inserted
replaced
1764:be3ada2e9d24 | 1765:1d7932bc2847 |
---|---|
19 ############################################################################### | 19 ############################################################################### |
20 | 20 |
21 select STDERR; $| = 1; | 21 select STDERR; $| = 1; |
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
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) |
25 ->write_file_expand('nginx.conf', <<'EOF'); | 25 ->write_file_expand('nginx.conf', <<'EOF'); |
26 | 26 |
27 %%TEST_GLOBALS%% | 27 %%TEST_GLOBALS%% |
28 | 28 |
29 daemon off; | 29 daemon off; |
58 EOF | 58 EOF |
59 | 59 |
60 $t->write_file('uwsgi_test_app.py', <<END); | 60 $t->write_file('uwsgi_test_app.py', <<END); |
61 | 61 |
62 def application(env, start_response): | 62 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 ]) | |
64 return b"SEE-THIS" | 69 return b"SEE-THIS" |
65 | 70 |
66 END | 71 END |
67 | 72 |
68 my $uwsgihelp = `uwsgi -h`; | 73 my $uwsgihelp = `uwsgi -h`; |
95 | 100 |
96 like(http_get('/var?b=127.0.0.1:' . port(8081)), qr/SEE-THIS/, | 101 like(http_get('/var?b=127.0.0.1:' . port(8081)), qr/SEE-THIS/, |
97 'uwsgi with variables'); | 102 'uwsgi with variables'); |
98 like(http_get('/var?b=u'), qr/SEE-THIS/, 'uwsgi with variables to upstream'); | 103 like(http_get('/var?b=u'), qr/SEE-THIS/, 'uwsgi with variables to upstream'); |
99 | 104 |
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 | |
100 ############################################################################### | 132 ############################################################################### |
101 | 133 |
102 sub http_get_headers { | 134 sub http_get_headers { |
103 my ($url, %extra) = @_; | 135 my ($url, %extra) = @_; |
104 return http(<<EOF, %extra); | 136 return http(<<EOF, %extra); |