root/lang/perl/HTTP-Engine/trunk/t/010_core/response_finalizer.t @ 17758

Revision 17758, 1.2 kB (checked in by tokuhirom, 5 years ago)

purge _build_connection

RevLine 
[17384]1use Test::Base;
2use HTTP::Engine::ResponseFinalizer;
3use HTTP::Engine;
[17758]4use t::Utils;
[17384]5
[17424]6plan tests => 9+(1*blocks);
[17384]7
8filters {
9    req => [qw/yaml/],
10    res => [qw/yaml/],
11};
12
13run {
14    my $block = shift;
[17758]15    my $req = req(
[17384]16        %{ $block->req || {} }
17    );
18    my $res = HTTP::Engine::Response->new(
19        %{ $block->res || {} }
20    );
21    HTTP::Engine::ResponseFinalizer->finalize( $req, $res );
22    eval $block->test;
23    die $@ if $@;
[17424]24
25    do {
26        local $@;
27        eval { HTTP::Engine::ResponseFinalizer->finalize( $req ) };
28        like $@, qr/argument missing: \$res/;
29    };
[17384]30};
31
32__END__
33
34=== default protocol
35--- req
36protocol: HTTP/1.0
37method: GET
38--- res
39status: 200
40--- test
41is $res->protocol, 'HTTP/1.0';
42is $res->header('Status'), 200;
43
44=== calcurate content_length
45--- req
46method: GET
47--- res
48body: foo
49--- test
50is $res->content_length, 3;
51
52=== if error
53--- req
54method: GET
55--- res
56status: 304
57body: FOO
58--- test
59is $res->content_length, undef;
60is $res->body, '';
61is $res->status, 304;
62
63
64=== default content type
65--- req
66method: GET
67--- res
68--- test
69is $res->content_type, 'text/html';
70
71=== truncate content in HEAD request(XXX is this valid response?)
72--- req
73method: HEAD
74--- res
75body: fooo
76--- test
77is $res->content_length, 4;
78is $res->body, '';
79
Note: See TracBrowser for help on using the browser.