HTTP::...peList(3pm)

✨ NAME ✨

HTTP::Headers::ActionPack::MediaTypeList β€” it's a Priority List, but make it media types πŸ’… (this is from the HTTP::...peList(3pm) manual page, bestie, so you're in the right place 🫢)


πŸŽ€ VERSION πŸŽ€

version 0.09 β€” she's vintage, she's stable, she's serving ✨


🌸 SYNOPSIS 🌸

okay so here's the whole vibe, copy-paste ready:

use HTTP::Headers::ActionPack::MediaTypeList;

# normal constructor
my $list = HTTP::Headers::ActionPack::MediaTypeList->new(
    HTTP::Headers::ActionPack::MediaType->new('audio/*', q => 0.2 ),
    HTTP::Headers::ActionPack::MediaType->new('audio/basic', q => 1.0 )
);

# you can also specify the 'q'
# rating independent of the
# media type definition
my $list = HTTP::Headers::ActionPack::MediaTypeList->new(
    [ 0.2 => HTTP::Headers::ActionPack::MediaType->new('audio/*', q => 0.2 )     ],
    [ 1.0 => HTTP::Headers::ActionPack::MediaType->new('audio/basic' ) ]
);

# or from a string
my $list = HTTP::Headers::ActionPack::MediaTypeList->new_from_string(
    'audio/*; q=0.2, audio/basic'
);

like. three whole ways to build the same list. pick your fighter πŸ₯Š


πŸ’– DESCRIPTION πŸ’–

So basically this is a subclass of the HTTP::Headers::ActionPack::PriorityList class, except it has some very specific media-type features bolted on. It's the default object that gets used to parse most of the "Accept" header, since those headers will lowkey always contain more than one media type. One is never enough, iykyk 😌


πŸ¦‹ METHODS πŸ¦‹

  • "iterable" β€” this hands you back the exact same data type as the parent class does: a two-element ARRAY ref holding the quality and the choice. BUT β€” and this is the moment β€” the choice element is a HTTP::Headers::ActionPack::MediaType object. It's also sorted in a super specific way so it lines up with RFC-2616 Sec14, which says, and I quote:
Media ranges can be overridden by more specific
media ranges or specific media types. If more
than one media range applies to a given type,
the most specific reference has precedence.

translation: specificity wins, periodt πŸ‘‘

  • "canonicalize_choice" β€” if you pass it a string, it builds you a brand new HTTP::Headers::ActionPack::MediaType object out of that string. If you pass it an object instead, it just hands that same object right back to you, untouched. no notes, no drama, no copies πŸ’…

πŸ‘‘ AUTHOR πŸ‘‘

Stevan Little <stevan.little@iinteractive.com> β€” the icon who did this πŸ’–


🌈 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 whole squad showed up, we love to see it 🫢✨


This software is copyright (c) 2012 by Infinity Interactive, Inc..

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in bestie, go wild πŸ¦‹


and that's the whole page, babe β€” this was HTTP::Headers::ActionPack::MediaTypeList, documented under perl v5.34.0, dated 2022-06-14. slay, go parse some Accept headers, ily πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from