changeset 428:e95c3340d94a

Tests: more SPDY tests for caching HEAD requests. It is explicitly checked that SYN_REPLY is not followed by DATA, also with proxy_buffering off.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 04 Jul 2014 13:19:13 +0400
parents daea9cf92c14
children 89f7a882d692
files spdy.t
diffstat 1 files changed, 27 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/spdy.t
+++ b/spdy.t
@@ -38,7 +38,7 @@ plan(skip_all => 'win32') if $^O eq 'MSW
 my $t = Test::Nginx->new()
 	->has(qw/http proxy cache limit_conn rewrite spdy realip/);
 
-$t->plan(74)->write_file_expand('nginx.conf', <<'EOF');
+$t->plan(76)->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
 
@@ -89,6 +89,12 @@ http {
             proxy_cache NAME;
             proxy_cache_valid 1m;
         }
+        location /proxy_buffering_off {
+            proxy_pass http://127.0.0.1:8081/;
+            proxy_cache NAME;
+            proxy_cache_valid 1m;
+            proxy_buffering off;
+        }
         location /t3.html {
             limit_conn conn 1;
         }
@@ -236,22 +242,38 @@ is($frame->{headers}->{':status'}, 405, 
 ok($frame, 'DATA frame with redirect');
 is($frame->{data}, 'body', 'DATA payload with redirect');
 
+# SYN_REPLY could be received with fin, followed by DATA
+
+$sess = new_session();
+$sid1 = spdy_stream($sess, { path => '/proxy/t2.html', method => 'HEAD' });
+
+$frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
+push @$frames, $_ for @{spdy_read($sess, all => [{ sid => $sid1 }])};
+ok(!grep ({ $_->{type} eq "DATA" } @$frames), 'proxy cache HEAD - no body');
+
 # ensure that HEAD-like requests, i.e., without response body, do not lead to
 # client connection close due to cache filling up with upstream response body
 
 TODO: {
 local $TODO = 'premature client connection close';
 
-$sess = new_session();
-$sid1 = spdy_stream($sess, { path => '/proxy/t2.html', method => 'HEAD' });
-$frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
-
 $sid2 = spdy_stream($sess, { path => '/' });
 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
 ok(grep ({ $_->{type} eq "SYN_REPLY" } @$frames), 'proxy cache headers only');
 
 }
 
+# HEAD on empty cache with proxy_buffering off
+
+$sess = new_session();
+$sid1 = spdy_stream($sess,
+	{ path => '/proxy_buffering_off/t2.html?1', method => 'HEAD' });
+
+$frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
+push @$frames, $_ for @{spdy_read($sess, all => [{ sid => $sid1 }])};
+ok(!grep ({ $_->{type} eq "DATA" } @$frames),
+	'proxy cache HEAD buffering off - no body');
+
 # simple proxy cache test
 
 $sess = new_session();