Courri...entType(3pm)
π Courriel::Header::ContentType π
okay bestie, welcome to the Courriel::Header::ContentType page from the User Contributed Perl Documentation β¨ (yes the header is all smushed in the terminal, we don't talk about it π
) β it's the content type for an email part, and she's lowkey iconic.
β¨ VERSION β¨
version 0.49 β she's got a number and she's proud of it π
πΈ SYNOPSIS πΈ
my $ct = $part->content_type();
print $ct->mime_type();
print $ct->charset();
my %attr = $ct->attributes();
while ( my ( $k, $v ) = each %attr ) {
print "$k => $v\n";
}
see how easy that is?? no cap, that's the whole vibe check right there π¦
π DESCRIPTION π
So this class is literally the main character version of a "Content-Type" header that's attached to an email part. Every single one of these headers always has a mime type β that part's non-negotiable β and then it may also carry extra info like a charset or whatever other attributes it's feeling that day π
Here's some typical headers, so you can see the range:
Content-Type: text/plain; charset=utf-8
Content-Type: multipart/alternative; boundary=abcdefghijk
Content-Type: image/jpeg; name="Filename.jpg"
not me getting emotional over multipart/alternative π she's so versatile.
π API π
This class supports the following methods, and honestly? she ate.
π§ Courriel::Header::ContentType->new_from_value( ... )
This one takes two parameters, name and value. The name is optional and defaults to Content-Type (she's flexible like that β¨).
The value gets parsed and split up into the mime type and the attributes.
π Courriel::Header::ContentType->new( ... )
This method creates a brand new object. It accepts the following parameters:
nameβ defaults to'Content-Type'.valueβ this is the full header value.mime_typeβ a string like"text/plain"or"multipart/alternative". This one is required, bestie, you cannot skip it.attributesβ a hash reference of attributes from the header, like a boundary, charset, etc. The keys are attribute names and the values can either be strings orCourriel::HeaderAttributeobjects. Any values that are strings get inflated into objects by the constructor. This is optional, and it can be an empty hash reference or omitted entirely.
π $ct->name()
The header name, usually "Content-Type".
β $ct->value()
The raw header value.
π $ct->mime_type()
Returns the mime type value that was passed to the constructor. BUT β plot twist β this value will be in all lower-case, no matter what original casing you handed over to the constructor. she normalizes, she doesn't judge π
π¦ $ct->charset()
Returns the charset for the content type, which will be the value found in the attributes, if one exists.
π $ct->attributes()
Returns a hash (not a reference, okay, a hash) 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. so the lowercase is just for the keys, the original vibe is still in there β¨
π $ct->is_binary()
Returns true unless the attachment looks like text data. Currently, this means that it has a charset defined and the charset is not binary.
π₯ $ct->attribute($key)
Given a key, returns the named Courriel::HeaderAttribute object. Obviously, this value can be undef if the attribute doesn't exist (no attribute, no object, that's just the rules π). Name lookup is case-insensitive.
π«Ά $ct->attribute_value($key)
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.
πΈ $ct->as_header_value()
Returns the object as a string suitable for a header value (but not folded). Note that this uses the original casing of the mime type as passed to the constructor β so the lowercase glow-up from mime_type() does not apply here, iykyk π
π EXTENDS π
This class extends Courriel::Header. family tree moment π
β¨ ROLES β¨
This class does the "Courriel::Role::HeaderWithAttributes" role. she's got range, she's got roles, she's booked and busy π
π¦ 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, bestie π
π SOURCE π
The source code repository for Courriel can be found at <https://github.com/houseabsolute/Courriel>.
π AUTHOR π
Dave Rolsky <autarch@urth.org> β the icon, the legend, the moment β
π COPYRIGHT AND LICENSE π
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. read it, bestie, it's giving responsible π«Ά
and that's the whole page!! π this was Courri...entType(3pm) (yes the terminal clipped her name, she's mysterious like that π) from perl v5.32.1, dated 2021-08-22. slay, no cap, go write some email-parsing code β¨ππ¦
π¦ where this page comes from
- debian bookworm: libcourriel-perl 0.49-1 Β· Artistic-2.0
- debian trixie: libcourriel-perl 0.49-1 Β· Artistic-2.0
- ubuntu jammy: libcourriel-perl 0.49-1 Β· Artistic-2.0
- ubuntu noble: libcourriel-perl 0.49-1 Β· Artistic-2.0
- ubuntu resolute: libcourriel-perl 0.49-1 Β· Artistic-2.0
- ubuntu stonking: libcourriel-perl 0.49-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms