HTTP::H...rs::Util(3)
π NAME π
ok so bestie, HTTP::Headers::Util β it's header value parsing utility functions. that's the whole vibe. it parses HTTP header values and helps you build valid ones back up. periodt. β¨
πΈ VERSION πΈ
this is version 7.03 π
π¦ SYNOPSIS π¦
ok so here's the whole entire vibe in two lines, look:
use HTTP::Headers::Util qw(split_header_words);
@values = split_header_words($h->header("Content-Type"));
that's it. that's the tea. π
β¨ DESCRIPTION β¨
so this module is literally just a lil collection of functions that help you parse and construct valid HTTP header values. and listen β none of these functions get exported by default, so you gotta ask for them by name, okay? no sneaky auto-importing here. π
here's what's available, bestie:
π split_header_words( @header_values )
ok so this one takes the header values you pass it as arguments and parses them into a list of anonymous arrays containing key/value pairs. it knows how to deal with ",", ";" and "=", and it also handles quoted values that come after "=". and here's a fun one β a list of space separated tokens gets parsed as if they were separated by ";". slay. π₯
and if the @header_values you pass in contains multiple values? they get treated like they were one single value separated by a comma ",". iconic.
so basically this function is your girl for parsing header fields that follow this syntax here (BNF straight from the HTTP/1.1 spec, except we relax the requirement for tokens β we're chill like that):
headers = #header
header = (token | parameter) *( [";"] (token | parameter))
token = 1*<any CHAR except CTLs or separators>
separators = "(" | ")" | "<" | ">" | "@"
| "," | ";" | ":" | "\" | <">
| "/" | "[" | "]" | "?" | "="
| "{" | "}" | SP | HT
quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
qdtext = <any TEXT except <">>
quoted-pair = "\" CHAR
parameter = attribute "=" value
attribute = token
value = token | quoted-string
each header gets represented by an anonymous array of key/value pairs. the keys are all forced to lower case. and the value for a simple token (like, one that's not part of a parameter) is undef. also ngl, syntactically incorrect headers will not necessarily be parsed the way you'd want them to be β so don't come for her if your garbage input gives garbage output. π
ok this is way easier to show than to explain, so examples, bestie:
split_header_words('foo="bar"; port="80,81"; DISCARD, BAR=baz');
split_header_words('text/html; charset="iso-8859-1"');
split_header_words('Basic realm="\\"foo\\\\bar\\""');
and those return:
[foo=>'bar', port=>'80,81', discard=> undef], [bar=>'baz' ]
['text/html' => undef, charset => 'iso-8859-1']
[basic => undef, realm => "\"foo\\bar\""]
and OMG here's a secret β if you do not want the function converting tokens and attribute keys to lower case, just call it as _split_header_words instead (yeah, with a leading underscore π). lowercase is cancelled, we're going full caps now. π
π join_header_words( @arrays )
this one does the exact opposite of what split_header_words() does. she takes a list of anonymous arrays as arguments (or honestly, a plain list of key/value pairs works too) and produces a single header value. attribute values get quoted if they need it. no cap. β¨
example time:
join_header_words(["text/plain" => undef, charset => "iso-8859/1"]);
join_header_words("text/plain" => undef, charset => "iso-8859/1");
both of those return this string right here:
text/plain; charset="iso-8859/1"
see? symmetrical. the way that she just reverses everything. obsessed. π«Ά
π AUTHOR π
Gisle Aas <gisle@activestate.com> β the icon, the moment, the legend. π
π COPYRIGHT AND LICENSE π
this software is copyright (c) 1994 by Gisle Aas.
and it's free software, bestie β you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in freedom, fr fr. π¦
π okay that's the whole page!! this was HTTP::H...rs::Util(3) from User Contributed Perl Documentation, rendered on 2026-07-23 with perl v5.42.2. tysm for reading, go parse some headers, ily, bye bestie!! πβ¨ππ«Ά
π¦ where this page comes from
- fedora 43: perl-HTTP-Message 7.03-1.fc43 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND CC0-1.0
- fedora 44: perl-HTTP-Message 7.03-1.fc44 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND CC0-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms