/
response.t
77 lines (71 loc) · 2.15 KB
/
response.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use v6;
use Test;
use HTTP::Supply::Response;
use lib 't/lib';
use HTTP::Supply::Response::Test;
my @tests =
%(
source => 'http-response-basic.txt',
expected => ([
200,
[
'::server-protocol' => 'HTTP/1.1',
'::server-reason-phrase' => 'OK',
content-type => 'text/plain',
content-length => '14',
],
"Hello World!\r\n",
],),
),
%(
source => 'http-response-no-length.txt',
expected => ([
200,
[
'::server-protocol' => 'HTTP/1.1',
'::server-reason-phrase' => 'OK',
content-type => 'text/plain',
],
"Hello World!\r\n",
],),
),
%(
source => 'http-response-pipeline.txt',
expected => ([
200,
[
'::server-protocol' => 'HTTP/1.1',
'::server-reason-phrase' => 'OK',
content-type => 'application/json; charset=utf8',
content-length => '21',
],
qq[\{"hello":"world"}\r\n\r\n],
], [
200,
[
'::server-protocol' => 'HTTP/1.1',
'::server-reason-phrase' => 'Pretty Good',
content-type => 'text/plain; charset=utf8',
transfer-encoding => 'chunked',
trailer => 'Magic',
],
"aababcabcd",
[
'magic' => 'off',
],
], [
200,
[
'::server-protocol' => 'HTTP/1.1',
'::server-reason-phrase' => 'Freaking Amazing',
content-type => 'text/html; charset=latin-1',
content-length => '27',
],
"<em>Neat-o Mosquito!</em>\r\n",
]),
),
;
my $tester = HTTP::Supply::Response::Test.new(:@tests);
$tester.run-tests(:reader<file>);
$tester.run-tests(:reader<socket>);
done-testing;