Fixed a bug where c->read didn't work properly, and added some tests for parse_on_dem...
[catagits/Catalyst-Runtime.git] / t / lib / TestAppOnDemand / Controller / Body.pm
diff --git a/t/lib/TestAppOnDemand/Controller/Body.pm b/t/lib/TestAppOnDemand/Controller/Body.pm
new file mode 100644 (file)
index 0000000..aca4a5e
--- /dev/null
@@ -0,0 +1,29 @@
+package TestAppOnDemand::Controller::Body;
+
+use strict;
+use base 'Catalyst::Base';
+
+use Data::Dump ();
+
+sub params : Local {
+    my ( $self, $c ) = @_;
+
+    $c->res->body( Data::Dump::dump( $c->req->body_parameters ) );
+}
+
+sub read : Local {
+    my ( $self, $c ) = @_;
+    
+    # read some data
+    my @chunks;
+    
+    while ( my $data = $c->read( 10_000 ) ) {
+        push @chunks, $data;
+    }
+
+    $c->res->content_type( 'text/plain');
+    
+    $c->res->body( join ( '|', map { length $_ } @chunks ) );
+}
+
+1;
\ No newline at end of file