File: live_engine_response_headers.t

package info (click to toggle)
libcatalyst-perl 5.90132-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,016 kB
  • sloc: perl: 11,061; makefile: 7
file content (47 lines) | stat: -rw-r--r-- 1,555 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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' ) {
        is( $response->header('Content-Length'),
            $content_length, 'Response Header Content-Length' )
            or diag $response->content;
        is( length($response->content),
            $response->header('Content-Length'),
            'GET method content' );
    }
}