HTTP::M...rtParser(3)
πΈ NAME πΈ
HTTP::MultiPartParser β it's the HTTP MultiPart Parser, bestie. Low-level, no drama, just vibes and octets. You're reading the User Contributed Perl Documentation page for HTTP::M...rtParser(3), and yes the name is abbreviated in the header because the terminal is a hater. π
β¨ SYNOPSIS β¨
Okay so here's the whole flow, look:
$parser = HTTP::MultiPartParser->new(
boundary => $boundary,
on_header => $on_header,
on_body => $on_body,
);
while ($octets = read_octets_from_body()) {
$parser->parse($octets);
}
$parser->finish;
That's it. That's the entire relationship. π«Ά
π¦ DESCRIPTION π¦
So this class is giving low-level API energy for processing MultiPart MIME data streams β the kind that conform to MultiPart types as defined in RFC 2616 <http://tools.ietf.org/html/rfc2616#section-3.7.2>. It parses, it doesn't judge. No cap. β¨
π METHODS π
π new
$parser = HTTP::MultiPartParser->new( %attributes );
This constructor returns an instance of HTTP::MultiPartParser. The valid attributes include:
boundary(Mandatory)
boundary => $value
This is the unquoted and unescaped boundary parameter value straight out of the Content-Type header field. Heads up: the boundary parameter value consists of a restricted set of characters as defined in RFC 2046 <http://tools.ietf.org/html/rfc2046#section-5.1.1>. The whole guest list is:
DIGIT / ALPHA / "'" / "(" / ")" /
"+" / "_" / "," / "-" / "." /
"/" / ":" / "=" / "?"
Literally only those, bestie. Don't try to sneak anything else in. π
on_header(Mandatory)
on_header => $callback->($header)
This callback gets invoked when the header of a part has successfully been received. And it's a one-time thing β the callback will only be invoked once for each part. Iconic behaviour honestly. π
on_header_as
on_header_as => 'unparsed' | 'lines'
This one defines the $header value that gets passed to the on_header callback. Two flavours, pick your fighter:
unparsedβ the callback is invoked with an octet string containing the unparsed header. Raw. Unfiltered. Main character energy. π¦linesβ the callback is invoked with an ARRAY reference, where each element of the array is a header line. Folding whitespace is removed from all lines, and header continuation lines are unwrapped. Tidy and slay. β¨
on_body(Mandatory)
on_body => $callback->($chunk, $final)
This callback gets invoked whenever there's any data available for the body of a part. Heads up though β it may be invoked multiple times for each part, so don't go assuming it's a one-and-done situation. It's a group chat, not a DM. π¬
on_error
on_error => $callback->($message)
This callback gets invoked anytime an error occurs in the parser. And fr fr, once you receive an error, the parser is no longer useful in its current state. It's done. It's over. π
max_preamble_size
max_preamble_size => 32768
max_header_size
max_header_size => 32768
π parse
$parser->parse($octets);
Parses the given octets. That's the whole thing. Feed it octets, it parses them. π
β finish
$parser->finish;
Finish the parsing. Wrapping it up, closing the loop, saying goodbye. π
π§ reset
$parser->reset;
Resets the state of the parser. Fresh start, clean slate, rebranding era. π
π₯ is_aborted
$boolean = $parser->is_aborted;
Returns true if an error has occurred in the parser. A vibe check for your parser's wellbeing, basically. π
π DIAGNOSTICS π
(F) Usage: %sβ Method called with wrong number of arguments. You passed the wrong amount of stuff. It's giving "read the synopsis". π
πΈ SEE ALSO πΈ
- RFC 2616 section 3.7.2 Multipart Types <http://tools.ietf.org/html/rfc2616#section-3.7.2>
- RFC 2046 section 5.1.1 Common Syntax <http://tools.ietf.org/html/rfc2046#section-5.1.1>
- RFC 2388 multipart/form-data <http://tools.ietf.org/html/rfc2388>
π«Ά SUPPORT π«Ά
π Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker at <https://github.com/chansen/p5-http-multipartparser/issues>. And the best part? You will be notified automatically of any progress on your issue. Obsessed with the transparency honestly. β¨
π¦ SOURCE CODE
This is open source software. The code repository is available for public review and contribution under the terms of the license.
<httsp://github.com/chansen/p5-http-multipartparser>
(Yeah, that's the URL exactly as written β httsp, not https. Not me fixing it, that's literally what it says. π)
git clone https://github.com/chansen/p5-http-multipartparser
π AUTHOR π
Christian Hansen "chansen@cpan.org" β the legend themselves. π«‘
π COPYRIGHT π
Copyright 2012-2017 by Christian Hansen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Slay, legally speaking. βοΈβ¨
Okay that's the whole page, bestie β brought to you by perl v5.42.0, dated 2019-08-09, and filed under HTTP::M...rtParser(3) in your favourite User Contributed Perl Documentation. Go forth and multipart. πππ¦
π¦ where this page comes from
- opensuse-leap 16.0: perl-HTTP-MultiPartParser 0.02-bp160.1.12 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms