HTTP::Headers::ActionPack::ContentNegotiation(3pm) | User Contributed Perl Documentation | HTTP::Headers::ActionPack::ContentNegotiation(3pm) |
HTTP::Headers::ActionPack::ContentNegotiation - A class to handle content negotiation
version 0.09
use HTTP::Headers::ActionPack; my $n = HTTP::Headers::ActionPack->new->get_content_negotiator; # matches text/html; charset="iso8859-1" $n->choose_media_type( ["text/html", "text/html;charset=iso8859-1" ], "text/html;charset=iso8859-1, application/xml" ); # matches en-US $n->choose_language( ['en-US', 'es'], "da, en-gb;q=0.8, en;q=0.7" ); # matches US-ASCII $n->choose_charset( [ "UTF-8", "US-ASCII" ], "US-ASCII, UTF-8" ); # matches gzip $n->choose_encoding( [ "gzip", "identity" }, "gzip, identity;q=0.7" );
This class provides a set of methods used for content negotiation. It makes full use of all the header objects, such as HTTP::Headers::ActionPack::MediaType, HTTP::Headers::ActionPack::MediaTypeList and HTTP::Headers::ActionPack::PriorityList.
Content negotiation is a tricky business, it needs to account for such things as the quality rating, order of elements (both in the header and in the list of provided items) and in the case of media types it gets even messier. This module does it's best to figure things out and do what is expected on it. We have included a number of examples from the RFC documents in our test suite as well.
HTTP::Negotiate
There is nothing wrong with this module, however it attempts to answer all the negotiation questions at once, whereas this module allows you to do it one thing at a time.
Stevan Little <stevan.little@iinteractive.com>
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.
2022-06-14 | perl v5.34.0 |