7 use lib "$FindBin::Bin/../lib";
9 use Test::More tests => 12;
10 use Catalyst::Test 'TestAppOnDemand';
12 use Catalyst::Request;
14 use HTTP::Request::Common;
16 # Test a simple POST request to make sure body parsing
17 # works in on-demand mode.
20 if ( $ENV{CATALYST_SERVER} ) {
21 skip "Using remote server", 12;
28 'http://localhost/body/query_params?wibble=wobble',
29 'Content-Type' => 'application/x-www-form-urlencoded',
30 'Content' => 'foo=bar&baz=quux'
33 my $expected = { wibble => 'wobble' };
35 ok( my $response = request($request), 'Request' );
36 ok( $response->is_success, 'Response Successful 2xx' );
41 eval '$params = ' . $response->content,
46 is_deeply( $params, $expected, 'Catalyst::Request query parameters' );
53 'http://localhost/body/params?wibble=wobble',
54 'Content-Type' => 'application/x-www-form-urlencoded',
55 'Content' => 'foo=bar&baz=quux'
58 my $expected = { foo => 'bar', baz => 'quux', wibble => 'wobble' };
60 ok( my $response = request($request), 'Request' );
61 ok( $response->is_success, 'Response Successful 2xx' );
66 eval '$params = ' . $response->content,
71 is_deeply( $params, $expected, 'Catalyst::Request body and query parameters' );
74 # Test reading chunks of the request body using $c->read
79 'http://localhost/body/read',
80 'Content-Type' => 'text/plain',
81 'Content' => 'x' x 105_000
84 my $expected = '10000|10000|10000|10000|10000|10000|10000|10000|10000|10000|5000';
86 ok( my $response = request($request), 'Request' );
87 ok( $response->is_success, 'Response Successful 2xx' );
88 is( $response->content_type, 'text/plain', 'Response Content-Type' );
89 is( $response->content, $expected, 'Response Content' );