Courri...osition(3pm)

✨ NAME ✨

Courriel::Header::Disposition β€” bestie, this is the content disposition for an email part πŸ’Œ


πŸ’« VERSION πŸ’«

version 0.49


πŸŽ€ SYNOPSIS πŸŽ€

my $disp = $part->content_disposition();
print $disp->is_inline();
print $disp->is_attachment();
print $disp->filename();

my %attr = $disp->attributes();
while ( my ( $k, $v ) = each %attr ) {
    print "$k => $v\n";
}

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so this class is literally the whole vibe of a Content-Disposition header that's stuck onto an email part. What do those headers even do? They tell you whether a part should be treated as an attachment or whether it should just be shown to the user directly. And it may also carry info about the attachment's filename, creation date, etc. So basically: receipts for your files πŸ’…

Here are some typical headers, no cap:

Content-Disposition: inline

Content-Disposition: multipart/alternative; boundary=abcdefghijk

Content-Disposition: attachment; filename="Filename.jpg"

Content-Disposition: attachment; filename="foo-bar.jpg";
  creation-date="Tue, 31 May 2011 09:41:13 -0700"

πŸ‘‘ API πŸ‘‘

This class supports the following methods, bestie β€” take notes πŸ“

🌸 Courriel::Header::Disposition->new_from_value( ... )

This one takes two parameters, name and value. The name is optional and defaults to Content-Disposition.

The value gets parsed and split up into the disposition and the attributes. Slay.

🌸 Courriel::Header::Disposition->new( ... )

This method makes a brand new object. It accepts these parameters:

  • name β€” this defaults to 'Content-Type'.
  • value β€” this is the full header value.
  • disposition β€” this should usually either be inline or attachment. In theory, the RFCs allow other values πŸ‘€
  • attributes β€” a hash reference of attributes from the header, like a filename, creation date, size, etc. The keys are attribute names, and the values can either be strings or Courriel::HeaderAttribute objects. Values that are strings will be inflated into objects by the constructor. This one is optional, and can be an empty hash reference or omitted entirely.

🌸 $ct->name()

The header name, usually Content-Disposition.

🌸 $ct->value()

The raw header value.

🌸 $disp->disposition()

Returns the disposition value that got passed to the constructor.

🌸 $disp->is_inline()

Returns true if the disposition is not equal to attachment.

🌸 $disp->is_attachment()

Returns true if the disposition is equal to attachment.

🌸 $disp->filename()

Returns the filename it found in the attributes, or undef.

🌸 $disp->creation_datetime(), $disp->last_modified_datetime(), $disp->read_datetime()

These methods go looking for a corresponding attribute (creation-date, etc.) and hand you back a DateTime object representing that attribute's value, if it exists πŸ’–

🌸 $disp->attributes()

Returns a hash (not a reference, ok?) of the attributes passed to the constructor.

Attributes are Courriel::HeaderAttribute objects.

The keys of the hash are all lower case, though the original casing is preserved in the name() returned by the Courriel::HeaderAttribute object.

🌸 $disp->attribute($key)

Give it a key, it gives you back the named Courriel::HeaderAttribute object. Obviously this value can be undef if the attribute doesn't exist. Name lookup is case-insensitive, periodt.

🌸 $disp->attribute_value($key)

Give it a key, it gives you back the named attribute's value as a string. Obviously this value can be undef if the attribute doesn't exist. Name lookup is case-insensitive.

The attribute is a Courriel::HeaderAttribute object.

🌸 $disp->as_header_value()

Returns the object as a string suitable for a header value (but not folded).


πŸ’œ EXTENDS πŸ’œ

This class extends Courriel::Header.


🧚 ROLES 🧚

This class does the Courriel::Role::HeaderWithAttributes role. Iconic behaviour, honestly.


⭐ SUPPORT ⭐

Bugs may be submitted at <https://github.com/houseabsolute/Courriel/issues>.

I am also usually active on IRC as autarch on irc://irc.perl.org. Come say hi 🫢


🌈 SOURCE 🌈

The source code repository for Courriel can be found at <https://github.com/houseabsolute/Courriel>.


πŸ’– AUTHOR πŸ’–

Dave Rolsky <autarch@urth.org>


This software is Copyright (c) 2021 by Dave Rolsky.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

The full text of the license can be found in the LICENSE file included with this distribution.


Okay that's the whole page, bestie πŸ’… This was Courri...osition(3pm) from perl v5.32.1, dated 2021-08-22 β€” go forth and dispose of your content, responsibly ✨