changeset 1354:c0075a0a2ba9

Tests: added realip test on http post read phase.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 04 Jul 2018 23:46:29 +0300
parents 65730ba03b42
children afe541649054
files realip.t
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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(<<EOF, socket => $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 {