5 use lib "$FindBin::Bin/../lib";
7 use Test::More tests => 18;
8 use Catalyst::Test 'TestApp';
9 use HTTP::Request::Common;
13 foreach my $method (qw(HEAD GET)) {
14 my $expected = join( ', ', 1 .. 10 );
16 my $request = HTTP::Request::Common->can($method)
17 ->( 'http://localhost/engine/response/headers/one' );
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' );
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),
37 'HEAD method content is empty' );
39 elsif ( $method eq 'GET' ) {
40 # method name is echo'd back in content-body (twice under debug),
41 # which accounts for difference in content length. In normal
42 # cases the Content-Length should be the same regardless
43 # of whether it's a GET or HEAD request.
46 if ( $ENV{CATALYST_SERVER} ) {
47 skip "Using remote server", 2;
49 my $diff = TestApp->debug ? 2 : 1;
50 is( $response->header('Content-Length'),
51 $content_length - $diff, 'Response Header Content-Length' )
52 or diag $response->content;
53 is( length($response->content),
54 $response->header('Content-Length'),
55 'GET method content' );