# HG changeset patch # User Sergey Kandaurov # Date 1404465553 -14400 # Node ID e95c3340d94a712600c6b5dac00b7d8f82fe679b # Parent daea9cf92c1414f9d68283bfac4214b95b0122df 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. diff --git a/spdy.t b/spdy.t --- 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();