# HG changeset patch # User Sergey Kandaurov # Date 1530737189 -10800 # Node ID c0075a0a2ba90f0c1aa7db15052f63db0822349c # Parent 65730ba03b42defc9da94fab5d2b1401ad26c5c3 Tests: added realip test on http post read phase. diff --git a/realip.t b/realip.t --- a/realip.t +++ b/realip.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http realip/); +my $t = Test::Nginx->new()->has(qw/http realip rewrite/); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -41,8 +41,13 @@ http { server { listen 127.0.0.1:8080; + listen 127.0.0.1:8081; server_name localhost; + if ($server_port = 8081) { + return 204; + } + location / { } location /custom { real_ip_header X-Real-IP-Custom; @@ -71,7 +76,7 @@ EOF plan(skip_all => 'no 127.0.0.1 on host') if http_get('/') !~ /X-IP: 127.0.0.1/m; -$t->plan(7); +$t->plan(8); ############################################################################### @@ -113,6 +118,14 @@ X-Forwarded-For: 127.0.0.1 EOF +my $s = IO::Socket::INET->new('127.0.0.1:' . port(8081)); +like(http(< $s), qr/ 204 .*192.0.2.1/s, 'realip post read'); +GET / HTTP/1.0 +Host: localhost +X-Real-IP: 192.0.2.1 + +EOF + ############################################################################### sub http_xff {