comparison h2.t @ 699:5768830f01c4

Tests: HTTP/2 test for CONTINUATION in the middle of header field.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 17 Sep 2015 20:05:26 +0300
parents f86c8314d205
children e28787665f99
comparison
equal deleted inserted replaced
698:f86c8314d205 699:5768830f01c4
30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; 30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
31 plan(skip_all => 'IO::Socket::SSL too old') if $@; 31 plan(skip_all => 'IO::Socket::SSL too old') if $@;
32 32
33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) 33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/)
34 ->has(qw/limit_conn rewrite realip shmem/) 34 ->has(qw/limit_conn rewrite realip shmem/)
35 ->has_daemon('openssl')->plan(195); 35 ->has_daemon('openssl')->plan(196);
36 36
37 $t->write_file_expand('nginx.conf', <<'EOF'); 37 $t->write_file_expand('nginx.conf', <<'EOF');
38 38
39 %%TEST_GLOBALS%% 39 %%TEST_GLOBALS%%
40 40
663 663
664 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 664 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
665 is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'CONTINUATION - fragment 2'); 665 is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'CONTINUATION - fragment 2');
666 is($frame->{headers}->{'x-referer'}, 'foo', 'CONTINUATION - fragment 3'); 666 is($frame->{headers}->{'x-referer'}, 'foo', 'CONTINUATION - fragment 3');
667 667
668 # CONTINUATION - in the middle of request header field
669
670 TODO: {
671 local $TODO = 'not yet';
672
673 $sess = new_session();
674 $sid = new_stream($sess, { continuation => [ 2, 4, 1, 5 ], headers => [
675 { name => ':method', value => 'HEAD', mode => 1 },
676 { name => ':scheme', value => 'http', mode => 0 },
677 { name => ':path', value => '/', mode => 0 },
678 { name => ':authority', value => 'localhost', mode => 1 }]});
679 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
680
681 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
682 is($frame->{headers}->{':status'}, 200, 'CONTINUATION - in header field');
683
684 }
685
668 # frame padding 686 # frame padding
669 687
670 $sess = new_session(); 688 $sess = new_session();
671 $sid = new_stream($sess, { padding => 42, headers => [ 689 $sid = new_stream($sess, { padding => 42, headers => [
672 { name => ':method', value => 'GET', mode => 0 }, 690 { name => ':method', value => 'GET', mode => 0 },
1813 my $path = $uri->{path} || '/'; 1831 my $path = $uri->{path} || '/';
1814 my $headers = $uri->{headers}; 1832 my $headers = $uri->{headers};
1815 my $body = $uri->{body}; 1833 my $body = $uri->{body};
1816 my $prio = $uri->{prio}; 1834 my $prio = $uri->{prio};
1817 my $dep = $uri->{dep}; 1835 my $dep = $uri->{dep};
1836 my $split = ref $uri->{continuation} && $uri->{continuation} || [];
1818 1837
1819 my $pad = defined $uri->{padding} ? $uri->{padding} : 0; 1838 my $pad = defined $uri->{padding} ? $uri->{padding} : 0;
1820 my $padlen = defined $uri->{padding} ? 1 : 0; 1839 my $padlen = defined $uri->{padding} ? 1 : 0;
1821 my $bpad = defined $uri->{body_padding} ? $uri->{body_padding} : 0; 1840 my $bpad = defined $uri->{body_padding} ? $uri->{body_padding} : 0;
1822 my $bpadlen = defined $uri->{body_padding} ? 1 : 0; 1841 my $bpadlen = defined $uri->{body_padding} ? 1 : 0;
1855 } 1874 }
1856 1875
1857 $input = pack("B*", '001' . ipack(5, $uri->{table_size})) . $input 1876 $input = pack("B*", '001' . ipack(5, $uri->{table_size})) . $input
1858 if defined $uri->{table_size}; 1877 if defined $uri->{table_size};
1859 1878
1879 my @input;
1880 for my $length (@$split) {
1881 my $offset = length($input[-1]) || 0;
1882 push @input, substr $input, $offset, $length, "";
1883 }
1884 push @input, $input;
1885
1860 # set length, attach headers, padding, priority 1886 # set length, attach headers, padding, priority
1861 1887
1862 my $hlen = length($input) + $pad + $padlen; 1888 my $hlen = length($input[0]) + $pad + $padlen;
1863 $hlen += 5 if $flags & 0x20; 1889 $hlen += 5 if $flags & 0x20;
1864 $buf |= pack_length($hlen); 1890 $buf |= pack_length($hlen);
1865 1891
1866 $buf .= pack 'C', $pad if $padlen; # Pad Length? 1892 $buf .= pack 'C', $pad if $padlen; # Pad Length?
1867 $buf .= pack 'NC', $dep, $prio if $flags & 0x20; 1893 $buf .= pack 'NC', $dep, $prio if $flags & 0x20;
1868 $buf .= $input; 1894 $buf .= $input[0];
1869 $buf .= (pack 'C', 0) x $pad if $padlen; # Padding 1895 $buf .= (pack 'C', 0) x $pad if $padlen; # Padding
1896
1897 shift @input;
1898
1899 while (@input) {
1900 $input = shift @input;
1901 $flags = @input ? 0x0 : 0x4;
1902 $buf .= pack_length(length($input));
1903 $buf .= pack("CC", 0x9, $flags);
1904 $buf .= pack("N", $ctx->{last_stream});
1905 $buf .= $input;
1906 }
1870 1907
1871 if (defined $body) { 1908 if (defined $body) {
1872 $buf .= pack_length(length($body) + $bpad + $bpadlen); 1909 $buf .= pack_length(length($body) + $bpad + $bpadlen);
1873 my $flags = $bpadlen ? 0x8 : 0x0; 1910 my $flags = $bpadlen ? 0x8 : 0x0;
1874 $buf .= pack 'CC', 0x0, 0x1 | $flags; # DATA, END_STREAM 1911 $buf .= pack 'CC', 0x0, 0x1 | $flags; # DATA, END_STREAM