Name

SPVM::Mojo::Content::MultiPart - HTTP multipart content

Description

Mojo::Content::MultiPart class in SPVM is a container for HTTP multipart content, based on RFC 7230, RFC 7231 and RFC 2388.

Usage

use Mojo::Content::MultiPart;

my $multi = Mojo::Content::MultiPart->new;
$multi->parse("Content-Type: multipart/mixed; boundary=---foobar");
my $single = $multi->parts->[4];

Super Class

Mojo::Content

Events

part

Emitted when a new Mojo::Content::Single part starts.

$multi->on(part => method : void ($multi : Mojo::Content::MultiPart, $single : Mojo::Content::Single) {
  
});

Fields

parts

has parts : Mojo::Content[];

Content parts embedded in this multipart content, usually Mojo::Content::Single objects.

Class Methods

Instance Methods

body_contains

method body_contains : int ($chunk : string);

Check if content parts contain a specific string.

body_size

method body_size : int ();

Content size in bytes.

build_boundary

method build_boundary : string ();

Generate a suitable boundary for content and add it to Content-Type header.

clone

method clone : Mojo::Content::MultiPart ();

Return a new Mojo::Content::MultiPart object cloned from this content if possible, otherwise return undef.

get_body_chunk

method get_body_chunk : string ($offset : int);

Get a chunk of content starting from a specific position. Note that it might not be possible to get the same chunk twice if content was generated dynamically.

is_multipart

method is_multipart : int ();

True, this is a Mojo::Content::MultiPart object.

See Also

Copyright & License

Copyright (c) 2025 Yuki Kimoto

MIT License