docs and correct middleware order
[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
12{
13 package MyApp::Controller::Root;
14
15 use base 'Catalyst::Controller';
16
17 sub test :Local {
18 my ($self, $c) = @_;
19 $c->response->body("This is the body");
20 }
21
22 package MyApp;
23 use Catalyst;
24
25 MyApp->setup;
26}
27
28$INC{'MyApp/Controller/Root.pm'} = __FILE__;
29
30Test::More::ok(MyApp->setup);
31
32ok my $psgi = MyApp->psgi_app, 'build psgi app';
33
34test_psgi $psgi, sub {
35 my $cb = shift;
36 my $res = $cb->(GET "/root/test");
37 is $res->code, 200, 'OK';
38 is $res->content, 'This is the body', 'correct body';
39 is $res->content_length, 16, 'correct length';
40};
41
42test_psgi $psgi, sub {
43 my $cb = shift;
44 my $res = $cb->(HEAD "/root/test");
45 is $res->code, 200, 'OK';
46 is $res->content, '', 'correct body';
47 is $res->content_length, 16, 'correct length';
48};
49
50done_testing;