CONTENTS

NAME

Catalyst::Action::DeserializeMultiPart - Deserialize Data in a Multipart Request

SYNOPSIS

package Foo::Controller::Bar;

__PACKAGE__->config(
    # see Catalyst::Action::Deserialize for standard config
);

sub begin :ActionClass('DeserializeMultiPart') DeserializePart('REST') {}

DESCRIPTION

This action will deserialize multipart HTTP POST, PUT, OPTIONS and DELETE requests. It is a simple extension of Catalyst::Action::Deserialize with the exception that rather than using the entire request body (which may contain multiple sections), it will look for a single part in the request body named according to the DeserializePart attribute on that action (defaulting to REST). If a part is found under that name, it then proceeds to deserialize the request as normal based on the content-type of that individual part. If no such part is found, the request would be processed as if no data was sent.

This module's code will only come into play if the following conditions are met:

CONFIGURING HTTP::Body

By default, HTTP::Body parses multipart/* requests as an HTTP::Body::OctetStream. HTTP::Body::OctetStream does not separate out the individual parts of the request body. In order to make use of the individual parts, HTTP::Body must be told which content types to map to HTTP::Body::MultiPart. This module makes the assumption that you would like to have all multipart/mixed requests parsed by HTTP::Body::MultiPart module. This is done by a package variable inside HTTP::Body: $HTTP::Body::Types (a HASH ref).

WARNING: As this module modifies the behaviour of HTTP::Body globally, adding it to an application can have unintended consequences as multipart bodies will be parsed differently from before.

Feel free to add other content-types to this hash if needed or if you would prefer that multipart/mixed NOT be added to this hash, simply delete it after loading this module.

# in your controller
use Catalyst::Action::DeserializeMultiPart;

delete $HTTP::Body::Types->{'multipart/mixed'};
$HTTP::Body::Types->{'multipart/my-crazy-content-type'} = 'HTTP::Body::MultiPart';

SEE ALSO

This is a simple sub-class of Catalyst::Action::Deserialize.

AUTHORS

See Catalyst::Action::REST for authors.

LICENSE

You may distribute this code under the same terms as Perl itself.