Furl::Headers(3pm)

πŸ“¦
version 3.15 Β· 3 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– 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 this Furl::Headers object. 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