Furl::Headers(3pm)
π Furl::Headers π
okay bestie, sit down, hydrate, because we're about to talk about Furl::Headers β it's the HTTP Headers object from the Furl fam, and it lives in the User Contributed Perl Documentation section of the manual, section 3pm. Think of it as the lil' clipboard where all your HTTP headers hang out. πβ¨
πΈ NAME πΈ
Furl::Headers β an HTTP Headers object. that's it, that's the whole vibe. it holds headers. it's giving organized. π
π¦ SYNOPSIS π¦
my $headers = Furl::Headers->new(\%headers);
(yeah, the synopsis is literally just the constructor β keep reading, there's more π«Ά)
β¨ CONSTRUCTOR β¨
my $headers = Furl::Headers->new(\%headers);β makes you a brand new headers object π
It takes exactly one argument, and that argument is a hashref. And here's the rule, no cap: every key of the hashref MUST be lower-cased. lowercase keys only, bestie, it's not a suggestion. π
The format of the argument looks like this:
+{
'content-length' => [30],
'set-cookies' => ['auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT', '_twitter_sess=JKLJBNBLKSFJBLKSJBLKSJLKJFLSDJFjkDKFUFIOSDUFSDVjOTUzNzUwNTE2%250AZWFiMWRiNDZhMDcwOWEwMWQ5IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--d9ce07496a22525bc178jlkhafklsdjflajfl411; domain=.twitter.com; path=/'],
}
see how the values are arrayrefs? yeah. multiple values per key, iconic. π
π INSTANCE METHODS π
my @values = $headers->header($key);β grab the header value as an array. all the values, not just one. πmy $values_joined = $headers->header($key);β grab the header value in scalar context. and heads up bestie, this is not the first value of the header. nope. it's literally the same as doing:
my $values = join(", ", $headers->header($key))
$headers->header($key, $val);$headers->header($key, \@val);β set a new value for a header. you can pass a single value, or an arrayref of values. your call, main character. β¨$headers->remove_header($key);β delete that key from the headers. bye bye πmy @h = $headers->flatten();β gets you pairs of keys and values. nice and flat. π₯my @keys = $headers->keys();my @keys = $headers->header_field_names();β returns the keys of the headers as an array. and the return value does not contain duplicated values β no repeats, we don't do that here. π«πmy $str = $headers->as_string();β returns the header fields as a formatted MIME header. fancy. πmy $val = $headers->referer()my $val = $headers->expires()my $val = $headers->last_modified()my $val = $headers->if_modified_since()my $val = $headers->content_type()my $val = $headers->content_length()my $val = $headers->content_encoding()
all of these are shortcuts for the popular headers. same energy, less typing. slay. π
$headers->clone();β returns a copy of thisFurl::Headersobject. a whole twin. πͺπ«Ά
π SEE ALSO π
HTTP::Headersβ go say hi, iykyk π
that's the whole page bestie, you ate it. go forth and header responsibly. π¦πΈ
this page is from perl v5.40.1, dated 2025-10-18, and it's the Furl::Headers(3pm) manpage β mwah, thanks for reading, love u, bye! πβ¨π
π¦ where this page comes from
- ubuntu resolute: libfurl-perl 3.15-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libfurl-perl 3.15-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms