# HG changeset patch # User Sergey Kandaurov # Date 1442509526 -10800 # Node ID 5768830f01c416c2c279e1d588283f469be3feee # Parent f86c8314d205bd151981127d5ca45217b412fc9e Tests: HTTP/2 test for CONTINUATION in the middle of header field. diff --git a/h2.t b/h2.t --- 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(195); + ->has_daemon('openssl')->plan(196); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -665,6 +665,24 @@ is($frame, undef, 'CONTINUATION - fragme is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'CONTINUATION - fragment 2'); is($frame->{headers}->{'x-referer'}, 'foo', 'CONTINUATION - fragment 3'); +# CONTINUATION - in the middle of request header field + +TODO: { +local $TODO = 'not yet'; + +$sess = new_session(); +$sid = new_stream($sess, { continuation => [ 2, 4, 1, 5 ], headers => [ + { name => ':method', value => 'HEAD', mode => 1 }, + { name => ':scheme', value => 'http', mode => 0 }, + { name => ':path', value => '/', mode => 0 }, + { name => ':authority', value => 'localhost', mode => 1 }]}); +$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "HEADERS" } @$frames; +is($frame->{headers}->{':status'}, 200, 'CONTINUATION - in header field'); + +} + # frame padding $sess = new_session(); @@ -1815,6 +1833,7 @@ sub new_stream { my $body = $uri->{body}; my $prio = $uri->{prio}; my $dep = $uri->{dep}; + my $split = ref $uri->{continuation} && $uri->{continuation} || []; my $pad = defined $uri->{padding} ? $uri->{padding} : 0; my $padlen = defined $uri->{padding} ? 1 : 0; @@ -1857,17 +1876,35 @@ sub new_stream { $input = pack("B*", '001' . ipack(5, $uri->{table_size})) . $input if defined $uri->{table_size}; + my @input; + for my $length (@$split) { + my $offset = length($input[-1]) || 0; + push @input, substr $input, $offset, $length, ""; + } + push @input, $input; + # set length, attach headers, padding, priority - my $hlen = length($input) + $pad + $padlen; + my $hlen = length($input[0]) + $pad + $padlen; $hlen += 5 if $flags & 0x20; $buf |= pack_length($hlen); $buf .= pack 'C', $pad if $padlen; # Pad Length? $buf .= pack 'NC', $dep, $prio if $flags & 0x20; - $buf .= $input; + $buf .= $input[0]; $buf .= (pack 'C', 0) x $pad if $padlen; # Padding + shift @input; + + while (@input) { + $input = shift @input; + $flags = @input ? 0x0 : 0x4; + $buf .= pack_length(length($input)); + $buf .= pack("CC", 0x9, $flags); + $buf .= pack("N", $ctx->{last_stream}); + $buf .= $input; + } + if (defined $body) { $buf .= pack_length(length($body) + $bpad + $bpadlen); my $flags = $bpadlen ? 0x8 : 0x0;