comparison h2_server_push.t @ 1734:f7170c7acf3a

Tests: added HTTP/2 tests for PUSH_PROMISE with CONTINUATION.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 17 Sep 2021 19:16:31 +0300
parents 144c6ce732e4
children 236d038dc04a
comparison
equal deleted inserted replaced
1733:e306bd77321d 1734:f7170c7acf3a
21 ############################################################################### 21 ###############################################################################
22 22
23 select STDERR; $| = 1; 23 select STDERR; $| = 1;
24 select STDOUT; $| = 1; 24 select STDOUT; $| = 1;
25 25
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite gzip/)->plan(42) 26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite gzip/)->plan(54)
27 ->write_file_expand('nginx.conf', <<'EOF'); 27 ->write_file_expand('nginx.conf', <<'EOF');
28 28
29 %%TEST_GLOBALS%% 29 %%TEST_GLOBALS%%
30 30
31 daemon off; 31 daemon off;
104 location /arg { 104 location /arg {
105 http2_push $arg_push; 105 http2_push $arg_push;
106 return 204; 106 return 204;
107 } 107 }
108 108
109 location /continuation {
110 http2_push /push?arg="$args$args$args$args";
111 return 204;
112 }
113
109 location /push { 114 location /push {
110 return 200 PROMISED; 115 return 200 PROMISED;
111 } 116 }
112 117
113 location /gzip.html { 118 location /gzip.html {
418 $frames = $s->read(all => [{ sid => 2, fin => 1 }]); 423 $frames = $s->read(all => [{ sid => 2, fin => 1 }]);
419 424
420 ($frame) = grep { $_->{type} eq "PUSH_PROMISE" && $_->{sid} == $sid } @$frames; 425 ($frame) = grep { $_->{type} eq "PUSH_PROMISE" && $_->{sid} == $sid } @$frames;
421 is($frame->{headers}->{':scheme'}, 'https', 'scheme https'); 426 is($frame->{headers}->{':scheme'}, 'https', 'scheme https');
422 427
428 # CONTINUATION
429
430 $s = Test::Nginx::HTTP2->new();
431 $sid = $s->new_stream({ path => '/continuation?x=' . ('X' x 4096) });
432 $frames = $s->read(all => [{ sid => 1, fin => 1 }, { sid => 2, fin => 1 }]);
433
434 @$frames = grep { $_->{promised} } @$frames;
435 is(@$frames, 2, 'continuation - frames');
436
437 $frame = shift @$frames;
438 is($frame->{type}, 'PUSH_PROMISE', 'continuation - PUSH_PROMISE');
439 is($frame->{length}, 16384, 'continuation - PUSH_PROMISE length');
440 is($frame->{flags}, 0, 'continuation - PUSH_PROMISE flags');
441 is($frame->{sid}, $sid, 'continuation - PUSH_PROMISE sid');
442 is($frame->{promised}, 2, 'continuation - promised stream');
443
444 $frame = shift @$frames;
445 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION');
446 is($frame->{flags}, 4, 'continuation - CONTINUATION flags');
447 is($frame->{headers}->{':authority'}, 'localhost', 'continuation - authority');
448 is($frame->{headers}->{':scheme'}, 'http', 'continuation - scheme');
449 is($frame->{headers}->{':method'}, 'GET', 'continuation - method');
450 like($frame->{headers}->{':path'}, qr!^/push!, 'continuation - path');
451
423 ############################################################################### 452 ###############################################################################
424 453
425 sub gunzip_like { 454 sub gunzip_like {
426 my ($in, $re, $name) = @_; 455 my ($in, $re, $name) = @_;
427 456