Tests: add realip tests for multiple X-Forwarded-For headers.
diff --git a/realip.t b/realip.t index bd81426..fb15b76 100644 --- a/realip.t +++ b/realip.t
@@ -65,7 +65,7 @@ plan(skip_all => 'no 127.0.0.1 on host') if http_get('/1') !~ /X-IP: 127.0.0.1/m; -$t->plan(4); +$t->plan(6); ############################################################################### @@ -74,9 +74,32 @@ 'realip multi'); like(http_xff('/1', '192.0.2.1, 10.0.1.1, 127.0.0.1'), qr/^X-IP: 127.0.0.1/m, 'realip recursive off'); -like(http_xff('/2', '192.0.2.1, 10.0.1.1, 127.0.0.1'), +like(http_xff('/2', '10.0.1.1, 192.0.2.1, 127.0.0.1'), qr/^X-IP: 192.0.2.1/m, 'realip recursive on'); +TODO: { + +local $TODO = 'not yet'; + +like(http(<<EOF), qr/^X-IP: 10.0.1.1/m, 'realip multi xff recursive off'); +GET /1 HTTP/1.0 +Host: localhost +X-Forwarded-For: 192.0.2.1 +X-Forwarded-For: 127.0.0.1, 10.0.1.1 + +EOF + +like(http(<<EOF), qr/^X-IP: 192.0.2.1/m, 'realip multi xff recursive on'); +GET /2 HTTP/1.0 +Host: localhost +X-Forwarded-For: 10.0.1.1 +X-Forwarded-For: 192.0.2.1 +X-Forwarded-For: 127.0.0.1 + +EOF + +} + ############################################################################### sub http_xff {