Commit | Line | Data |
fbcc39ad |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
7 | use lib "$FindBin::Bin/../../../lib"; |
8 | |
d8c66af5 |
9 | use Test::More tests => 80; |
fbcc39ad |
10 | use Catalyst::Test 'TestApp'; |
11 | |
d8c66af5 |
12 | for ( 1 .. 10 ) { |
13 | |
14 | # test direct streaming |
15 | { |
16 | ok( my $response = request('http://localhost/streaming'), 'Request' ); |
17 | ok( $response->is_success, 'Response Successful 2xx' ); |
18 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
19 | is( $response->content,, <<'EOF', 'Content is a stream' ); |
fbcc39ad |
20 | foo |
21 | bar |
22 | baz |
23 | EOF |
1775342a |
24 | } |
d8c66af5 |
25 | |
26 | # test streaming by passing a handle to $c->res->body |
27 | SKIP: |
28 | { |
29 | if ( $ENV{CATALYST_SERVER} ) { |
30 | skip "Using remote server", 4; |
31 | } |
32 | |
33 | my $file = "$FindBin::Bin/../../../../01use.t"; |
34 | my $fh = IO::File->new( $file, 'r' ); |
35 | my $buffer; |
36 | if ( defined $fh ) { |
37 | $fh->read( $buffer, 1024 ); |
38 | $fh->close; |
39 | } |
40 | |
41 | ok( my $response = request('http://localhost/action/streaming/body'), |
42 | 'Request' ); |
43 | ok( $response->is_success, 'Response Successful 2xx' ); |
44 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
45 | is( $response->content, $buffer, 'Content is read from filehandle' ); |
3dc4d7e9 |
46 | } |
3dc4d7e9 |
47 | } |