Courriel::Header::Disposition(3pm) | User Contributed Perl Documentation | Courriel::Header::Disposition(3pm) |
Courriel::Header::Disposition - The content disposition for an email part
version 0.48
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"; }
This class represents the contents of a "Content-Disposition" header attached to an email part. Such headers indicate whether or not a part should be considered an attachment or should be displayed to the user directly. This header may also include information about the attachment's filename, creation date, etc.
Here are some typical headers:
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"
This class supports the following methods:
This takes two parameters, "name" and "value". The "name" is optional, and defaults to "Content-Disposition".
The "value" is parsed and split up into the disposition and attributes.
This method creates a new object. It accepts the following parameters:
This defaults to 'Content-Type'.
This is the full header value.
This should usually either be "inline" or "attachment".
In theory, the RFCs allow other values.
A hash reference of attributes from the header, such as a filename, creation date, size, etc. The keys are attribute names and the values can either be strings or Courriel::HeaderAttribute objects. Values which are strings will be inflated into objects by the constructor.
This is optional, and can be an empty hash reference or omitted entirely.
The header name, usually "Content-Disposition".
The raw header value.
Returns the disposition value passed to the constructor.
Returns true if the disposition is not equal to "attachment".
Returns true if the disposition is equal to "attachment".
Returns the filename found in the attributes, or "undef".
These methods look for a corresponding attribute ("creation-date", etc.) and return a DateTime object representing that attribute's value, if it exists.
Returns a hash (not a reference) 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.
Given a key, returns the named Courriel::HeaderAttribute object. Obviously, this value can be "undef" if the attribute doesn't exist. Name lookup is case-insensitive.
Given a key, returns 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.
Returns the object as a string suitable for a header value (but not folded).
This class extends Courriel::Header.
This class does the "Courriel::Role::HeaderWithAttributes" role.
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".
The source code repository for Courriel can be found at <https://github.com/houseabsolute/Courriel>.
Dave Rolsky <autarch@urth.org>
This software is Copyright (c) 2019 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.
2019-07-19 | perl v5.28.1 |