@@ -25,7 +25,7 @@ eval { require FCGI; };
25
25
plan(skip_all => ' FCGI not installed' ) if $@ ;
26
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
29
-> write_file_expand(' nginx.conf' , <<'EOF' );
30
30
31
31
%%TEST_GLOBALS%%
@@ -59,6 +59,37 @@ $t->run()->waitforsocket('127.0.0.1:' . port(8081));
59
59
like(http_get_headers(' /' ), qr / SEE-THIS/ ,
60
60
' fastcgi request with many ignored headers' );
61
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
+ }
92
+
62
93
# ##############################################################################
63
94
64
95
sub http_get_headers {
@@ -100,9 +131,16 @@ sub fastcgi_daemon {
100
131
while ( $request -> Accept() >= 0 ) {
101
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
138
print <<EOF ;
104
139
Location: http://localhost/redirect
105
140
Content-Type: text/html
141
+ X-Forwarded-For: $xfwd
142
+ X-Cookie: $cookie
143
+ X-Foo: $foo
106
144
107
145
SEE-THIS
108
146
$count
0 commit comments