fixed failing test and maybe travis
[catagits/Catalyst-Runtime.git] / t / aggregate / live_engine_response_headers.t
CommitLineData
fbcc39ad 1use strict;
2use warnings;
3
4use FindBin;
42da66a9 5use lib "$FindBin::Bin/../lib";
fbcc39ad 6
7use Test::More tests => 18;
8use Catalyst::Test 'TestApp';
9use HTTP::Request::Common;
10
11my $content_length;
12
88806717 13foreach my $method (qw(HEAD GET)) {
fbcc39ad 14 my $expected = join( ', ', 1 .. 10 );
15
16 my $request = HTTP::Request::Common->can($method)
17 ->( 'http://localhost/engine/response/headers/one' );
18
19 ok( my $response = request($request), 'Request' );
20 ok( $response->is_success, 'Response Successful 2xx' );
21 is( $response->code, 200, 'Response Code' );
22 is( $response->header('X-Catalyst-Action'),
23 'engine/response/headers/one', 'Test Action' );
24 is( $response->header('X-Header-Catalyst'),
25 'Cool', 'Response Header X-Header-Catalyst' );
26 is( $response->header('X-Header-Cool'),
27 'Catalyst', 'Response Header X-Header-Cool' );
28 is( $response->header('X-Header-Numbers'),
29 $expected, 'Response Header X-Header-Numbers' );
30
31 use bytes;
32 if ( $method eq 'HEAD' ) {
33 $content_length = $response->header('Content-Length');
34 ok( $content_length > 0, 'Response Header Content-Length' );
35 is( length($response->content),
36 0,
37 'HEAD method content is empty' );
38 }
39 elsif ( $method eq 'GET' ) {
40 # method name is echo'd back in content-body, which
41 # accounts for difference in content length. In normal
42 # cases the Content-Length should be the same regardless
43c58153 43 # of whether it's a GET or HEAD request.
fbcc39ad 44 SKIP:
45 {
46 if ( $ENV{CATALYST_SERVER} ) {
47 skip "Using remote server", 2;
48 }
49 is( $response->header('Content-Length'),
50 $content_length - 1, 'Response Header Content-Length' );
51 is( length($response->content),
52 $response->header('Content-Length'),
53 'GET method content' );
54 }
55 }
56}