Mercurial > hg > nginx-tests
comparison fastcgi_header_params.t @ 1763:b7d0e595e927
Tests: fastcgi tests for combining headers.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 30 May 2022 21:28:56 +0300 |
parents | 882267679006 |
children |
comparison
equal
deleted
inserted
replaced
1762:5ad8f0b5fa0f | 1763:b7d0e595e927 |
---|---|
23 | 23 |
24 eval { require FCGI; }; | 24 eval { require FCGI; }; |
25 plan(skip_all => 'FCGI not installed') if $@; | 25 plan(skip_all => 'FCGI not installed') if $@; |
26 plan(skip_all => 'win32') if $^O eq 'MSWin32'; | 26 plan(skip_all => 'win32') if $^O eq 'MSWin32'; |
27 | 27 |
28 my $t = Test::Nginx->new()->has(qw/http fastcgi/)->plan(1) | 28 my $t = Test::Nginx->new()->has(qw/http fastcgi/)->plan(4) |
29 ->write_file_expand('nginx.conf', <<'EOF'); | 29 ->write_file_expand('nginx.conf', <<'EOF'); |
30 | 30 |
31 %%TEST_GLOBALS%% | 31 %%TEST_GLOBALS%% |
32 | 32 |
33 daemon off; | 33 daemon off; |
56 | 56 |
57 ############################################################################### | 57 ############################################################################### |
58 | 58 |
59 like(http_get_headers('/'), qr/SEE-THIS/, | 59 like(http_get_headers('/'), qr/SEE-THIS/, |
60 'fastcgi request with many ignored headers'); | 60 'fastcgi request with many ignored headers'); |
61 | |
62 TODO: { | |
63 local $TODO = 'not yet' unless $t->has_version('1.23.0'); | |
64 | |
65 my $r; | |
66 | |
67 $r = http(<<EOF); | |
68 GET / HTTP/1.0 | |
69 Host: localhost | |
70 X-Forwarded-For: foo | |
71 X-Forwarded-For: bar | |
72 X-Forwarded-For: bazz | |
73 Cookie: foo | |
74 Cookie: bar | |
75 Cookie: bazz | |
76 Foo: foo | |
77 Foo: bar | |
78 Foo: bazz | |
79 | |
80 EOF | |
81 | |
82 like($r, qr/X-Forwarded-For: foo, bar, bazz/, | |
83 'fastcgi with multiple X-Forwarded-For headers'); | |
84 | |
85 like($r, qr/X-Cookie: foo; bar; bazz/, | |
86 'fastcgi with multiple Cookie headers'); | |
87 | |
88 like($r, qr/X-Foo: foo, bar, bazz/, | |
89 'fastcgi with multiple unknown headers'); | |
90 | |
91 } | |
61 | 92 |
62 ############################################################################### | 93 ############################################################################### |
63 | 94 |
64 sub http_get_headers { | 95 sub http_get_headers { |
65 my ($url, %extra) = @_; | 96 my ($url, %extra) = @_; |
98 | 129 |
99 my $count; | 130 my $count; |
100 while( $request->Accept() >= 0 ) { | 131 while( $request->Accept() >= 0 ) { |
101 $count++; | 132 $count++; |
102 | 133 |
134 my $xfwd = $ENV{HTTP_X_FORWARDED_FOR} || ''; | |
135 my $cookie = $ENV{HTTP_COOKIE} || ''; | |
136 my $foo = $ENV{HTTP_FOO} || ''; | |
137 | |
103 print <<EOF; | 138 print <<EOF; |
104 Location: http://localhost/redirect | 139 Location: http://localhost/redirect |
105 Content-Type: text/html | 140 Content-Type: text/html |
141 X-Forwarded-For: $xfwd | |
142 X-Cookie: $cookie | |
143 X-Foo: $foo | |
106 | 144 |
107 SEE-THIS | 145 SEE-THIS |
108 $count | 146 $count |
109 EOF | 147 EOF |
110 } | 148 } |