Cataly...tiPart(3pm)
π Catalyst::Action::DeserializeMultiPart(3pm) π
okay so bestie, welcome to the User Contributed Perl Documentation corner of the internet β¨ this little icon lives at Catalyst::Action::DeserializeMultiPart(3pm) and it's here to help you un-mangle multipart request bodies. let's get into it π
πΈ 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 π
so this action will deserialize multipart HTTP POST, PUT, OPTIONS and DELETE requests, no cap π
it's literally just a simple extension of Catalyst::Action::Deserialize, with one tiny little glow-up: instead of scarfing down the entire request body (which might have a bunch of sections in it, it's giving buffet π), it goes looking for one single part in the request body, named according to the "DeserializePart" attribute on that action (and if you don't say anything, it defaults 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 gets processed as if no data was sent at all. like, nothing. ghosted π»
this module's code will only come into play if the following conditions are met:
- the
"Content-type"of the request is"multipart/*"π - the request body (as returned by
$c->request->body) is not defined - there is a part of the request body (as returned by
$c->request->upload($DeserializePart)) available β¨
π§ CONFIGURING HTTP::Body π§
by default, HTTP::Body parses "multipart/*" requests as an HTTP::Body::OctetStream. and HTTP::Body::OctetStream does not separate out the individual parts of the request body β it's giving "one big blob, no notes" π
so to actually make use of the individual parts, HTTP::Body has to be told which content types to map to HTTP::Body::MultiPart. this module makes the assumption that you'd like to have all "multipart/mixed" requests parsed by the HTTP::Body::MultiPart module. and it does that through 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, because multipart bodies will be parsed differently from before. pls be aware bestie, this is not a small thing π
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. family tree energy π³β¨
π AUTHORS π
see Catalyst::Action::REST for authors. they ate, we're just vibing in their shadow π
π LICENSE π
you may distribute this code under the same terms as Perl itself. iconic behaviour, honestly π
that's the whole page bestie!! go forth and deserialize those multipart requests, you've got this ππ β¨
perl v5.40.1 Β· 2026-05-07 β mwah, tysm for reading, ily, byeeee ππ¦πΈ
π¦ where this page comes from
- ubuntu stonking: libcatalyst-action-rest-perl 1.22-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms