HTTP::...ionPack(3pm)
π NAME π
HTTP::Headers::ActionPack β HTTP Action, Adventure and Excitement π’β¨
(also it's a User Contributed Perl Documentation page, so like, iykyk)
π VERSION π
version 0.09 β she's a lil vintage bestie, and we love her for it π«Ά
β¨ SYNOPSIS β¨
okay bestie, watch this, it's giving main character energy:
use HTTP::Headers::ActionPack;
my $pack = HTTP::Headers::ActionPack->new;
my $media_type = $pack->create_header( 'Content-Type' => 'application/xml;charset=UTF-8' );
my $link = $pack->create( 'LinkHeader' => [ '</test/tree>', rel => "up" ] );
# auto-magic header inflation
# for multiple types
$pack->inflate( $http_headers_instance );
$pack->inflate( $http_request_instance );
$pack->inflate( $plack_request_instance );
auto-magic header inflation?? bestie that's not a feature that's a whole personality π
π¦ DESCRIPTION π¦
so like, this is a module that handles the inflation and deflation of complex HTTP header types. no cap. in many cases header values are just simple strings, right, very demure β but in some cases they're complex values with a LOT of information encoded in them, and that's when things get spicy. πΆοΈ
the goal of this module is to make the parsing and analysis of these headers as easy as just calling "inflate" on a compatible object (there's a list below, don't worry babe).
this top-level class is basically a Factory for creating instances of the other classes in this module. she's the girlboss making sure everyone else shows up. she's also got a bunch of convenience methods so the common cases are, like, easy to write. periodt.
π DEFAULT MAPPINGS π
this class ships with a whole set of default mappings between HTTP headers and the classes that can inflate them. here's the full list, no skips, no cuts, all of it:
Link HTTP::Headers::ActionPack::LinkList
Content-Type HTTP::Headers::ActionPack::MediaType
Accept HTTP::Headers::ActionPack::MediaTypeList
Accept-Charset HTTP::Headers::ActionPack::PriorityList
Accept-Encoding HTTP::Headers::ActionPack::PriorityList
Accept-Language HTTP::Headers::ActionPack::PriorityList
Date HTTP::Headers::ActionPack::DateHeader
Client-Date HTTP::Headers::ActionPack::DateHeader
Expires HTTP::Headers::ActionPack::DateHeader
Last-Modified HTTP::Headers::ActionPack::DateHeader
If-Unmodified-Since HTTP::Headers::ActionPack::DateHeader
If-Modified-Since HTTP::Headers::ActionPack::DateHeader
WWW-Authenticate HTTP::Headers::ActionPack::WWWAuthenticate
Authentication-Info HTTP::Headers::ActionPack::AuthenticationInfo
Authorization HTTP::Headers::ActionPack::Authorization
NOTE: the'Client-Date'header is often added by LWP onHTTP::Responseobjects. so if you see her, that's why. she's a guest, not a resident. π
π METHODS π
new( ?%mappings )β the constructor, she takes an option hash of header-name to class mappings, and those get added to (or override) the default mappings (scroll up for those, bestie). every class is expected to have a"new_from_string"method that can parse the string representation of the given header and hand you back an object. so like, each class has to know how to read her own mail. πmappingβ returns the set of mappings in this instance. that's it. that's the whole thing. πclassesβ returns the list of supported classes. by default that's the list of classes included in this module, but she'll ALSO grab any extra classes you specified in the%mappingsparameter to"new"(see above, babe, i'm not repeating myself). πget_content_negotiatorβ returns an instance ofHTTP::Headers::ActionPack::ContentNegotiation. go get 'em negotiator. ποΈcreate( $class_name, $args )β give her a$class_nameand$argsand she'll inflate the value using the class found in the"classes"list. if$argsis a string she calls"new_from_string"on the$class_name, but if$argsis an ARRAY ref, she dereferences the ARRAY and passes it to"new". two paths, one girlboss. π₯create_header( $header_name, $header_value )β give her a$header_nameand a$header_valueand she'll inflate the value using the class found in the mappings. if$header_valueis a string she calls"new_from_string"on the class mapped to the$header_name, but if$header_valueis an ARRAY ref, she dereferences the ARRAY and passes it to"new". same energy, different entry point. β¨inflate( $http_headers )inflate( $http_request )inflate( $plack_request )inflate( $web_request )β hand her either anHTTP::Headersinstance, anHTTP::Requestinstance, aPlack::Requestinstance, or aWeb::Requestinstance, and she'll inflate all the relevant headers and store the object in the same instance. one method, four glow-ups. π¦
in theory this should not negatively affect anything, since all the header objects overload the stringification operator, and most often the headers are treated as strings. BUT this is not for certain and care should be taken. so like, be careful bestie, i'm serious. π
π CAVEATS π
π Plack Compatibility
we have a test in the suite that checks to make sure any inflated header objects will pass between HTTP::Request and HTTP::Response objects, as well as Plack::Request and Plack::Response objects. she's tested, she's vetted, she's that girl. π―
a simple survey of most of the Plack::Handler subclasses shows that most of them will end up properly stringifying these header objects before sending them out. slay. the notable exceptions were the Apache handlers. not them. π
at the time of this writing, the solution for this would be for you to either stringify these objects prior to returning your Plack::Response, or to write a simple middleware component that would do that for you. in future versions we might provide just such a middleware (it would likely inflate the header objects on the request side as well). so like, watch this space. π
π Stringification
as mentioned above (bestie i literally just said this), all the header objects overload the stringification operator, so normal usage of them should just do what you would expect (stringify in a sensible way). she's sensible! she's got it together!
however this is not certain, and so care should be taken when passing object headers onto another library that is expecting strings. don't be out here handing a whole object to a library that asked for a string. that's rude. π
πΈ AUTHOR πΈ
Stevan Little <stevan.little@iinteractive.com> β the founder of the whole vibe. π
π«Ά CONTRIBUTORS π«Ά
- Andrew Nelson
<anelson@cpan.org> - Dave Rolsky
<autarch@urth.org> - Florian Ragwitz
<rafl@debian.org> - Jesse Luehrs
<doy@tozt.net> - Karen Etheridge
<ether@cpan.org>
the group chat. the squad. the ones who showed up. π
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2012 by Infinity Interactive, Inc. (yes there are two dots in the original, we're not touching it, it's iconic, periodt β¨).
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so like, go off, but respectfully. π
and that's the whole page bestie!! π she's built on perl v5.34.0 and this lil doc was born on 2022-06-14. mwah. π π¦πΈπ
π¦ where this page comes from
- debian bookworm: libhttp-headers-actionpack-perl 0.09-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhttp-headers-actionpack-perl 0.09-2 Β· 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