# HG changeset patch # User Sergey Kandaurov # Date 1442925496 -10800 # Node ID 626bc3a0fdaa1bb1dd6fa214b7918c1c7f226a7c # Parent 62dad59cfb671029582700b02848cb5d3628095d Tests: SPDY and HTTP/2 write handler tests. diff --git a/h2.t b/h2.t --- a/h2.t +++ b/h2.t @@ -32,7 +32,11 @@ 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(194); + ->has_daemon('openssl')->plan(196); + +# FreeBSD has a bug in not treating zero iovcnt as EINVAL + +$t->todo_alerts() unless $^O eq 'freebsd'; $t->write_file_expand('nginx.conf', <<'EOF'); @@ -215,7 +219,7 @@ foreach my $name ('localhost') { $t->write_file('t1.html', join('', map { sprintf "X%04dXXX", $_ } (1 .. 8202))); $t->write_file('tbig.html', - join('', map { sprintf "X%04dXXX", $_ } (1 .. 8202))); + join('', map { sprintf "XX%06dXX", $_ } (1 .. 100000))); $t->write_file('t2.html', 'SEE-THIS'); $t->write_file('t3.html', 'SEE-THIS'); @@ -1094,6 +1098,23 @@ is(@$frames, 1, 'positive window'); is(@$frames[0]->{type}, 'DATA', 'positive window - data'); is(@$frames[0]->{length}, 1, 'positive window - data length'); +# ask write handler in sending large response + +$sid = new_stream($sess, { path => '/tbig.html' }); + +h2_window($sess, 2**30, $sid); +h2_window($sess, 2**30); + +sleep 1; +$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "HEADERS" } @$frames; +is($frame->{headers}->{':status'}, 200, 'large response - HEADERS'); + +@data = grep { $_->{type} eq "DATA" } @$frames; +$sum = eval join '+', map { $_->{length} } @data; +is($sum, 1000000, 'large response - DATA'); + # SETTINGS_MAX_FRAME_SIZE $sess = new_session(); diff --git a/spdy.t b/spdy.t --- a/spdy.t +++ b/spdy.t @@ -37,7 +37,11 @@ plan(skip_all => 'Compress::Raw::Zlib no my $t = Test::Nginx->new() ->has(qw/http proxy cache limit_conn rewrite spdy realip shmem/); -$t->plan(82)->write_file_expand('nginx.conf', <<'EOF'); +# FreeBSD has a bug in not treating zero iovcnt as EINVAL + +$t->todo_alerts() unless $^O eq 'freebsd'; + +$t->plan(84)->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -121,6 +125,8 @@ EOF $t->write_file('t1.html', join('', map { sprintf "X%04dXXX", $_ } (1 .. 8202))); +$t->write_file('tbig.html', + join('', map { sprintf "XX%06dXX", $_ } (1 .. 100000))); $t->write_file('t2.html', 'SEE-THIS'); $t->write_file('t3.html', 'SEE-THIS'); @@ -426,6 +432,23 @@ spdy_window($sess, 1, $sid1); is(@$frames, 1, 'positive window - data'); is(@$frames[0]->{length}, 1, 'positive window - data length'); +# ask write handler in sending large response + +$sid1 = spdy_stream($sess, { path => '/tbig.html' }); + +spdy_window($sess, 2**30, $sid1); +spdy_window($sess, 2**30); + +sleep 1; +$frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); + +($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; +is($frame->{headers}->{':status'}, 200, 'large response - HEADERS'); + +@data = grep { $_->{type} eq "DATA" } @$frames; +$sum = eval join '+', map { $_->{length} } @data; +is($sum, 1000000, 'large response - DATA'); + # stream multiplexing $sess = new_session();