update version info
[catagits/Catalyst-Runtime.git] / t / head_middleware.t
CommitLineData
6ffef690 1use warnings;
2use strict;
3use Test::More;
4use HTTP::Request::Common;
5use Plack::Test;
6
7# Test to make sure we the order of some middleware is correct. Basically
8# we want to make sure that if the request is a HEAD we properly remove the
9# body BUT not so quickly that we fail to calculate the length. This test
10# exists mainly to prevent regressions.
11
09b86ef3 12{
6ffef690 13 package MyApp::Controller::Root;
09b86ef3 14 $INC{'MyApp/Controller/Root.pm'} = __FILE__;
6ffef690 15
16 use base 'Catalyst::Controller';
17
18 sub test :Local {
19 my ($self, $c) = @_;
20 $c->response->body("This is the body");
21 }
22
23 package MyApp;
24 use Catalyst;
25
be7d4054 26 Test::More::ok(MyApp->setup, 'setup app');
6ffef690 27}
28
6ffef690 29
6ffef690 30
31ok my $psgi = MyApp->psgi_app, 'build psgi app';
32
33test_psgi $psgi, sub {
34 my $cb = shift;
35 my $res = $cb->(GET "/root/test");
36 is $res->code, 200, 'OK';
37 is $res->content, 'This is the body', 'correct body';
38 is $res->content_length, 16, 'correct length';
39};
40
41test_psgi $psgi, sub {
42 my $cb = shift;
43 my $res = $cb->(HEAD "/root/test");
44 is $res->code, 200, 'OK';
45 is $res->content, '', 'correct body';
46 is $res->content_length, 16, 'correct length';
47};
48
49done_testing;