Courriel::Header(3pm)

πŸ’Œ Courriel::Header β€” a single header's name and value πŸ’Œ

okay bestie, welcome to Courriel::Header from the Courriel family (that's Courriel::Header(3pm) if you're being formal, which we are not). This is version 0.49, she's a little icon, let's go πŸŽ€


✨ VERSION ✨

version 0.49 β€” yes ma'am, that's the one πŸ’…


🌸 SYNOPSIS 🌸

my $subject = $headers->get('subject');
print $subject->value;

literally that's it. grab a header, print its value, slay. πŸ¦‹


πŸ’– DESCRIPTION πŸ’–

So this class represents one single header, okay? Just the one. And a header is made of exactly two things: a name and a value. That's the whole personality. name + value = the entire vibe. 🫢


πŸ‘‘ API πŸ‘‘

This class supports the following methods, and we're going through every single one because I love you:

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

Constructor time!! ✨ This method requires two attributes: name and value. Both of them have to be strings, no cap.

The name cannot be empty β€” like, it must have something in it, bestie, do not come in here with an empty name.

But the value? The value can be empty. She's allowed to be a little empty. It's fine. We don't judge. πŸ’œ

$header->name()

Returns the header name β€” literally the exact thing you passed to the constructor. Nothing more, nothing less. iconic behavior.

$header->value()

Returns the header value β€” again, exactly as passed to the constructor. periodt. 🌈

$header->as_string( charset => $charset )

This one returns the header name and value, with any necessary MIME encoding and folding done for you. Fancy! πŸŽ€

The charset parameter tells it what character set to use for MIME-encoding non-ASCII values. It defaults to utf8. And heads up: the charset name has to be one that the Encode module recognizes, or it's not gonna work, bestie. ⭐

$header->stream_to( output => $output, charset => ... )

She streams πŸ’« β€” this method sends the stringified header to the specified output.

That output can be:

  • a subroutine reference,
  • a filehandle,
  • or an object with a print() method.

And here's the fun part: the output may be sent as a single string, as a list of strings, or via multiple calls to the output. Any of those! Whatever she feels like! πŸ¦‹

For the deets on the charset parameter, go read the as_string() method documentation above. iykyk πŸ’…


🧚 ROLES 🧚

This class does the Courriel::Role::Streams role. That's where the streaming energy comes from, and we love that for her. πŸ’œ


🫢 SUPPORT 🫢

Found a bug? First of all, same. Second of all, bugs may be submitted at <https://github.com/houseabsolute/Courriel/issues>.

Also!! I am usually active on IRC as 'autarch' on irc://irc.perl.org. come say hi 🌸


πŸ“ SOURCE πŸ“

The source code repository for Courriel lives at <https://github.com/houseabsolute/Courriel>. go look at the code, it's giving open source excellence. ✨


πŸ‘‘ AUTHOR πŸ‘‘

Dave Rolsky <autarch@urth.org> β€” the main character, the legend, the one who wrote this. πŸ’–


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, it's important, no skimming. 😭


πŸ’€ lowkey reminder that name cannot be empty but value can β€” do not get it twisted bestie, that's the whole rule.

and that's the page!! this was Courriel::Header, documented under perl v5.32.1, dated 2021-08-22, and honestly? she ate. mwah πŸ’…πŸ’–βœ¨πŸ¦‹πŸŒΈ