File: Body.pm

package info (click to toggle)
libcatalyst-perl 5.90132-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,016 kB
  • sloc: perl: 11,061; makefile: 7
file content (41 lines) | stat: -rw-r--r-- 752 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package TestAppOnDemand::Controller::Body;

use strict;
use base 'Catalyst::Controller';

use Data::Dump ();

sub body_params : Local {
    my ( $self, $c ) = @_;

    $c->res->body( Data::Dump::dump( $c->req->body_parameters ) );
}

sub query_params : Local {
    my ( $self, $c ) = @_;

    $c->res->body( Data::Dump::dump( $c->req->query_parameters ) );
}

sub params : Local {
    my ( $self, $c ) = @_;

    $c->res->body( Data::Dump::dump( $c->req->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;