/
stringify-headers.t
50 lines (39 loc) · 1.01 KB
/
stringify-headers.t
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
#
# Test the parse_url() method
#
use v6;
use Test;
use LWP::Simple;
plan 6;
my @test = (
{ User-Agent => 'Opera/9.80 (WinNT; 6.0) Version/10.60' },
"User-Agent: Opera/9.80 (WinNT; 6.0) Version/10.60\r\n",
{ Connection => 'close' },
"Connection: close\r\n",
);
for @test -> %headers, $expected_str {
my $hdr_str = LWP::Simple.stringify_headers(%headers);
is($hdr_str, $expected_str, 'OK - ' ~ $hdr_str);
}
my $hdr = LWP::Simple.stringify_headers({
User-Agent => 'Chrome/5.0',
Accept-Encoding => 'gzip',
Accept-Language => 'en;q=1, it;q=0.8, no-NB;q=0.5, es;q=0.6',
Connection => 'keepalive',
});
ok(
$hdr.match('User-Agent: Chrome'),
'Composite headers are stringified correctly'
);
ok(
$hdr.match('Accept-Encoding: gzip'),
'Composite headers are stringified correctly'
);
ok(
$hdr.match('Connection: keepalive'),
'Composite headers are stringified correctly'
);
ok(
$hdr.match('Accept-Language: en;q=1'),
'Composite headers are stringified correctly'
);