Add tests to show that 5.80 broke ->req->parameters when you do on-demand parsing.
[catagits/Catalyst-Runtime.git] / t / aggregate / live_engine_request_body_demand.t
CommitLineData
878b821c 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
42da66a9 7use lib "$FindBin::Bin/../lib";
878b821c 8
cb5b55f9 9use Test::More tests => 12;
878b821c 10use Catalyst::Test 'TestAppOnDemand';
11
12use Catalyst::Request;
13use HTTP::Headers;
14use HTTP::Request::Common;
15
16# Test a simple POST request to make sure body parsing
17# works in on-demand mode.
18SKIP:
19{
20 if ( $ENV{CATALYST_SERVER} ) {
cb5b55f9 21 skip "Using remote server", 12;
878b821c 22 }
cb5b55f9 23
24 {
25 my $params;
26
27 my $request = POST(
28 'http://localhost/body/query_params?wibble=wobble',
29 'Content-Type' => 'application/x-www-form-urlencoded',
30 'Content' => 'foo=bar&baz=quux'
31 );
32
33 my $expected = { wibble => 'wobble' };
34
35 ok( my $response = request($request), 'Request' );
36 ok( $response->is_success, 'Response Successful 2xx' );
37
38 {
39 no strict 'refs';
40 ok(
41 eval '$params = ' . $response->content,
42 'Unserialize params'
43 );
44 }
45
46 is_deeply( $params, $expected, 'Catalyst::Request query parameters' );
47 }
48
878b821c 49 {
50 my $params;
51
52 my $request = POST(
cb5b55f9 53 'http://localhost/body/params?wibble=wobble',
878b821c 54 'Content-Type' => 'application/x-www-form-urlencoded',
55 'Content' => 'foo=bar&baz=quux'
56 );
57
cb5b55f9 58 my $expected = { foo => 'bar', baz => 'quux', wibble => 'wobble' };
878b821c 59
60 ok( my $response = request($request), 'Request' );
61 ok( $response->is_success, 'Response Successful 2xx' );
62
63 {
64 no strict 'refs';
65 ok(
66 eval '$params = ' . $response->content,
67 'Unserialize params'
68 );
69 }
70
cb5b55f9 71 is_deeply( $params, $expected, 'Catalyst::Request body and query parameters' );
878b821c 72 }
73
74 # Test reading chunks of the request body using $c->read
75 {
76 my $creq;
77
78 my $request = POST(
79 'http://localhost/body/read',
80 'Content-Type' => 'text/plain',
81 'Content' => 'x' x 105_000
82 );
83
84 my $expected = '10000|10000|10000|10000|10000|10000|10000|10000|10000|10000|5000';
85
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' );
90 }
91}