GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Mojo::Content::MultiPart(3) User Contributed Perl Documentation Mojo::Content::MultiPart(3)

Mojo::Content::MultiPart - HTTP multipart content

  use Mojo::Content::MultiPart;

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

Mojo::Content::MultiPart is a container for HTTP multipart content, based on RFC 7230 <https://tools.ietf.org/html/rfc7230>, RFC 7231 <https://tools.ietf.org/html/rfc7231> and RFC 2388 <https://tools.ietf.org/html/rfc2388>.

Mojo::Content::MultiPart inherits all events from Mojo::Content and can emit the following new ones.

  $multi->on(part => sub ($multi, $single) {...});

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

  $multi->on(part => sub ($multi, $single) {
    return unless $single->headers->content_disposition =~ /name="([^"]+)"/;
    say "Field: $1";
  });

Mojo::Content::MultiPart inherits all attributes from Mojo::Content and implements the following new ones.

  my $parts = $multi->parts;
  $multi    = $multi->parts([Mojo::Content::Single->new]);

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

Mojo::Content::MultiPart inherits all methods from Mojo::Content and implements the following new ones.

  my $bool = $multi->body_contains('foobarbaz');

Check if content parts contain a specific string.

  my $size = $multi->body_size;

Content size in bytes.

  my $boundary = $multi->build_boundary;

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

  my $clone = $multi->clone;

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

  my $bytes = $multi->get_body_chunk(0);

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.

  my $bool = $multi->is_multipart;

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

  my $multi = Mojo::Content::MultiPart->new;
  my $multi
    = Mojo::Content::MultiPart->new(parts => [Mojo::Content::Single->new]);
  my $multi
    = Mojo::Content::MultiPart->new({parts => [Mojo::Content::Single->new]});

Construct a new Mojo::Content::MultiPart object and subscribe to event "read" in Mojo::Content with default content parser.

Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
2021-12-08 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.