-
Notifications
You must be signed in to change notification settings - Fork 107
/
head_middleware.t
49 lines (37 loc) · 1.13 KB
/
head_middleware.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
use warnings;
use strict;
use Test::More;
use HTTP::Request::Common;
use Plack::Test;
# Test to make sure we the order of some middleware is correct. Basically
# we want to make sure that if the request is a HEAD we properly remove the
# body BUT not so quickly that we fail to calculate the length. This test
# exists mainly to prevent regressions.
{
package MyApp::Controller::Root;
$INC{'MyApp/Controller/Root.pm'} = __FILE__;
use base 'Catalyst::Controller';
sub test :Local {
my ($self, $c) = @_;
$c->response->body("This is the body");
}
package MyApp;
use Catalyst;
Test::More::ok(MyApp->setup, 'setup app');
}
ok my $psgi = MyApp->psgi_app, 'build psgi app';
test_psgi $psgi, sub {
my $cb = shift;
my $res = $cb->(GET "/root/test");
is $res->code, 200, 'OK';
is $res->content, 'This is the body', 'correct body';
is $res->content_length, 16, 'correct length';
};
test_psgi $psgi, sub {
my $cb = shift;
my $res = $cb->(HEAD "/root/test");
is $res->code, 200, 'OK';
is $res->content, '', 'correct body';
is $res->content_length, 16, 'correct length';
};
done_testing;