use Moose;
use namespace::autoclean;
+use Scalar::Util qw(openhandle);
extends 'Catalyst::Action';
use JSON;
-our $VERSION = '0.91';
+our $VERSION = '1.01';
$VERSION = eval $VERSION;
sub execute {
my $self = shift;
my ( $controller, $c, $test ) = @_;
- my $body = $c->request->body;
my $rbody;
- if ($body) {
- while (my $line = <$body>) {
- $rbody .= $line;
+ # could be a string or a FH
+ if ( my $body = $c->request->body ) {
+ if(openhandle $body) {
+ seek($body, 0, 0); # in case something has already read from it
+ while ( defined( my $line = <$body> ) ) {
+ $rbody .= $line;
+ }
+ } else {
+ $rbody = $body;
}
}