X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fhead_middleware.t;fp=t%2Fhead_middleware.t;h=1171c7ba4b1b422e257be1600bf0fab00c22d2e6;hb=6ffef690bbc5db6afd2592153565e578285888bf;hp=0000000000000000000000000000000000000000;hpb=59c1748aaf405246a97630e316a03603f933c393;p=catagits%2FCatalyst-Runtime.git diff --git a/t/head_middleware.t b/t/head_middleware.t new file mode 100644 index 0000000..1171c7b --- /dev/null +++ b/t/head_middleware.t @@ -0,0 +1,50 @@ +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; + + use base 'Catalyst::Controller'; + + sub test :Local { + my ($self, $c) = @_; + $c->response->body("This is the body"); + } + + package MyApp; + use Catalyst; + + MyApp->setup; +} + +$INC{'MyApp/Controller/Root.pm'} = __FILE__; + +Test::More::ok(MyApp->setup); + +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;