X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FDeserialize%2FXML%2FSimple.pm;h=4487f6e48a086497d8f672cd4fdbd0675079b86d;hb=cc188065d548c2c53c22000871a7d6dfab5c3c69;hp=b43d026a81124554dc026230b23e739cbc547b29;hpb=e527bba30dcea5108b0fb77416fcb4e8ee1e5a38;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/Deserialize/XML/Simple.pm b/lib/Catalyst/Action/Deserialize/XML/Simple.pm index b43d026..4487f6e 100644 --- a/lib/Catalyst/Action/Deserialize/XML/Simple.pm +++ b/lib/Catalyst/Action/Deserialize/XML/Simple.pm @@ -2,11 +2,11 @@ package Catalyst::Action::Deserialize::XML::Simple; use Moose; use namespace::autoclean; +use Scalar::Util qw(openhandle); extends 'Catalyst::Action'; -our $VERSION = '0.87'; -$VERSION = eval $VERSION; +# VERSION sub execute { my $self = shift; @@ -26,7 +26,10 @@ sub execute { my $xs = XML::Simple->new('ForceArray' => 0,); my $rdata; eval { - $rdata = $xs->XMLin( "$body" ); + if(openhandle $body){ # make sure we rewind the file handle + seek($body, 0, 0); # in case something has already read from it + } + $rdata = $xs->XMLin( $body ); }; if ($@) { return $@; @@ -44,4 +47,6 @@ sub execute { return 1; } +__PACKAGE__->meta->make_immutable; + 1;