| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::More; |
| 4 |
use Protocol::HTTP2::Client; |
| 5 |
use Protocol::HTTP2::Server; |
| 6 |
use lib 't/lib'; |
| 7 |
use PH2Test qw(fake_connect random_string); |
| 8 |
|
| 9 |
subtest 'client large headers' => sub { |
| 10 |
|
| 11 |
plan tests => 12; |
| 12 |
|
| 13 |
my $location = "https://www.example.com/"; |
| 14 |
my $on_done = sub { |
| 15 |
my ( $headers, $data ) = @_; |
| 16 |
}; |
| 17 |
my %common = ( |
| 18 |
':scheme' => 'http', |
| 19 |
':authority' => 'localhost:8000', |
| 20 |
':path' => '/', |
| 21 |
on_done => $on_done, |
| 22 |
); |
| 23 |
|
| 24 |
my $server; |
| 25 |
$server = Protocol::HTTP2::Server->new( |
| 26 |
on_request => sub { |
| 27 |
my ( $stream_id, $headers, $data ) = @_; |
| 28 |
my %h = (@$headers); |
| 29 |
for my $i ( 1 .. 6 ) { |
| 30 |
ok exists $h{"h$i"}, "h$i decoded ok"; |
| 31 |
} |
| 32 |
|
| 33 |
$server->response_stream( |
| 34 |
':status' => 302, |
| 35 |
stream_id => $stream_id, |
| 36 |
headers => [ |
| 37 |
location => $location |
| 38 |
], |
| 39 |
); |
| 40 |
|
| 41 |
}, |
| 42 |
); |
| 43 |
|
| 44 |
my $client = Protocol::HTTP2::Client->new; |
| 45 |
$client->request( |
| 46 |
%common, |
| 47 |
headers => [ |
| 48 |
'h1' => random_string(1000), |
| 49 |
'h2' => random_string(1000), |
| 50 |
'h3' => random_string(1000), |
| 51 |
'h4' => random_string(1000), |
| 52 |
'h5' => random_string(1000), |
| 53 |
'h6' => random_string(1000), |
| 54 |
], |
| 55 |
':method' => 'GET', |
| 56 |
)->request( |
| 57 |
%common, |
| 58 |
':method' => 'GET', |
| 59 |
headers => [ |
| 60 |
'h1' => random_string(5000), |
| 61 |
'h2' => random_string(5000), |
| 62 |
'h3' => random_string(5000), |
| 63 |
'h4' => random_string(5000), |
| 64 |
'h5' => random_string(5000), |
| 65 |
'h6' => random_string(5000), |
| 66 |
], |
| 67 |
); |
| 68 |
|
| 69 |
fake_connect( $server, $client ); |
| 70 |
}; |
| 71 |
|
| 72 |
done_testing; |