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