changeset 776:3fc382902cba

Tests: added HTTP/2 test for request body delayed in limit_req.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 05 Nov 2015 15:43:40 +0300
parents a6764c2a9f12
children cbd26265d9a3
files h2.t
diffstat 1 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/h2.t
+++ b/h2.t
@@ -32,7 +32,7 @@ plan(skip_all => 'IO::Socket::SSL too ol
 
 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/)
 	->has(qw/limit_conn rewrite realip shmem/)
-	->has_daemon('openssl')->plan(284);
+	->has_daemon('openssl')->plan(286);
 
 # Some systems may have also a bug in not treating zero writev iovcnt as EINVAL
 
@@ -52,6 +52,7 @@ http {
 
     proxy_cache_path %%TESTDIR%%/cache    keys_zone=NAME:1m;
     limit_conn_zone  $binary_remote_addr  zone=conn:1m;
+    limit_req_zone   $binary_remote_addr  zone=req:1m rate=1r/s;
 
     server {
         listen       127.0.0.1:8080 http2;
@@ -142,6 +143,11 @@ http {
             add_header X-Body "$request_body";
             proxy_pass http://127.0.0.1:8081/;
         }
+        location /proxy_limit_req/ {
+            add_header X-Body $request_body;
+            proxy_pass http://127.0.0.1:8081/;
+            limit_req  zone=req burst=2;
+        }
         location /cache/ {
             proxy_pass http://127.0.0.1:8081/;
             proxy_cache NAME;
@@ -1398,6 +1404,27 @@ is($frame->{headers}->{':status'}, '200'
 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
 is($frame->{headers}->{'x-body'}, 'TEST', 'request body in multiple frames');
 
+# request body delayed in limit_req
+
+$sess = new_session();
+$sid = new_stream($sess, { path => '/proxy_limit_req/', body => 'TEST' });
+$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
+
+($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
+is($frame->{headers}->{'x-body'}, 'TEST', 'request body - limit req');
+
+SKIP: {
+skip 'leaves coredump', 1 unless $t->has_version('1.9.7');
+
+$sid = new_stream($sess, { path => '/proxy_limit_req/', body => 'TEST2' });
+select undef, undef, undef, 1.1;
+$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
+
+($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
+is($frame->{headers}->{'x-body'}, 'TEST2', 'request body - limit req 2');
+
+}
+
 # malformed request body length not equal to content-length
 
 $sess = new_session();