X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FDeserialize%2FXML%2FSimple.pm;h=8d232bc7017273dc6d17409d685e605d5b87b1ba;hb=HEAD;hp=1b3072257c12b8d51e9f24fb65f4e08df1a007f1;hpb=ab8ab47a739539677817d6a7493b888c7a7815f6;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 1b30722..8d232bc 100644 --- a/lib/Catalyst/Action/Deserialize/XML/Simple.pm +++ b/lib/Catalyst/Action/Deserialize/XML/Simple.pm @@ -2,12 +2,10 @@ package Catalyst::Action::Deserialize::XML::Simple; use Moose; use namespace::autoclean; +use Scalar::Util qw(openhandle); extends 'Catalyst::Action'; -our $VERSION = '0.85'; -$VERSION = eval $VERSION; - sub execute { my $self = shift; my ( $controller, $c, $test ) = @_; @@ -26,7 +24,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 +45,6 @@ sub execute { return 1; } +__PACKAGE__->meta->make_immutable; + 1;