X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=trunk%2Ft%2Faggregate%2Flive_engine_response_headers.t;fp=trunk%2Ft%2Faggregate%2Flive_engine_response_headers.t;h=123b125a8ba7b3ec5178ec3673ecb5f4ebdac77d;hb=ceae39c522c2145a453188867dd581062795ecee;hp=0000000000000000000000000000000000000000;hpb=f436bc1bece2bcc2a04138068e5c22e70d9d6d35;p=catagits%2FCatalyst-Runtime.git diff --git a/trunk/t/aggregate/live_engine_response_headers.t b/trunk/t/aggregate/live_engine_response_headers.t new file mode 100644 index 0000000..123b125 --- /dev/null +++ b/trunk/t/aggregate/live_engine_response_headers.t @@ -0,0 +1,58 @@ +#!perl + +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../lib"; + +use Test::More tests => 18; +use Catalyst::Test 'TestApp'; +use HTTP::Request::Common; + +my $content_length; + +foreach my $method qw(HEAD GET) { + my $expected = join( ', ', 1 .. 10 ); + + my $request = HTTP::Request::Common->can($method) + ->( 'http://localhost/engine/response/headers/one' ); + + ok( my $response = request($request), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->code, 200, 'Response Code' ); + is( $response->header('X-Catalyst-Action'), + 'engine/response/headers/one', 'Test Action' ); + is( $response->header('X-Header-Catalyst'), + 'Cool', 'Response Header X-Header-Catalyst' ); + is( $response->header('X-Header-Cool'), + 'Catalyst', 'Response Header X-Header-Cool' ); + is( $response->header('X-Header-Numbers'), + $expected, 'Response Header X-Header-Numbers' ); + + use bytes; + if ( $method eq 'HEAD' ) { + $content_length = $response->header('Content-Length'); + ok( $content_length > 0, 'Response Header Content-Length' ); + is( length($response->content), + 0, + 'HEAD method content is empty' ); + } + elsif ( $method eq 'GET' ) { + # method name is echo'd back in content-body, which + # accounts for difference in content length. In normal + # cases the Content-Length should be the same regardless + # of whether it's a GET or HEAD request. + SKIP: + { + if ( $ENV{CATALYST_SERVER} ) { + skip "Using remote server", 2; + } + is( $response->header('Content-Length'), + $content_length - 1, 'Response Header Content-Length' ); + is( length($response->content), + $response->header('Content-Length'), + 'GET method content' ); + } + } +}