File: 04_continuation.t

package info (click to toggle)
libprotocol-http2-perl 1.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 416 kB
  • sloc: perl: 3,380; makefile: 7
file content (72 lines) | stat: -rw-r--r-- 1,822 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use strict;
use warnings;
use Test::More;
use Protocol::HTTP2::Client;
use Protocol::HTTP2::Server;
use lib 't/lib';
use PH2Test qw(fake_connect random_string);

subtest 'client large headers' => sub {

    plan tests => 12;

    my $location = "https://www.example.com/";
    my $on_done  = sub {
        my ( $headers, $data ) = @_;
    };
    my %common = (
        ':scheme'    => 'http',
        ':authority' => 'localhost:8000',
        ':path'      => '/',
        on_done      => $on_done,
    );

    my $server;
    $server = Protocol::HTTP2::Server->new(
        on_request => sub {
            my ( $stream_id, $headers, $data ) = @_;
            my %h = (@$headers);
            for my $i ( 1 .. 6 ) {
                ok exists $h{"h$i"}, "h$i decoded ok";
            }

            $server->response_stream(
                ':status' => 302,
                stream_id => $stream_id,
                headers   => [
                    location => $location
                ],
            );

        },
    );

    my $client = Protocol::HTTP2::Client->new;
    $client->request(
        %common,
        headers => [
            'h1' => random_string(1000),
            'h2' => random_string(1000),
            'h3' => random_string(1000),
            'h4' => random_string(1000),
            'h5' => random_string(1000),
            'h6' => random_string(1000),
        ],
        ':method' => 'GET',
    )->request(
        %common,
        ':method' => 'GET',
        headers   => [
            'h1' => random_string(5000),
            'h2' => random_string(5000),
            'h3' => random_string(5000),
            'h4' => random_string(5000),
            'h5' => random_string(5000),
            'h6' => random_string(5000),
        ],
    );

    fake_connect( $server, $client );
};

done_testing;