WWW::OAuth::Util(3pm)
π WWW::OAuth::Util π
okay so bestie, this is the WWW::OAuth::Util(3pm) page from the User Contributed Perl Documentation, and it's literally just the lil toolbox of helper functions that WWW::OAuth uses. no cap, it's short and it's useful and we're gonna get through it together π«Ά
β¨ NAME β¨
WWW::OAuth::Util β utility functions for WWW::OAuth πΈ
π SYNOPSIS π
use WWW::OAuth::Util 'form_urldecode', 'form_urlencode';
my $body_string = form_urlencode({foo => 'a b c', bar => [1, 2, 3]});
# bar=1&bar=2&bar=3&foo=a+b+c
my $ordered_pairs = form_urldecode($body_string);
# ['bar', '1', 'bar', '2', 'bar', '3', 'foo', 'a b c']
use WWW::OAuth::Util 'oauth_request';
my $container = oauth_request($http_request);
see how tidy that is?? chefs kiss π
π DESCRIPTION π
WWW::OAuth::Util is the vibes-holder for utility functions made to be used with WWW::OAuth. and the best part: all functions are exportable on demand. you ask for them, you get them, no surprise imports sneaking into your namespace like an uninvited plus-one π
π¦ FUNCTIONS π¦
π form_urldecode
my $param_pairs = form_urldecode($body_string);
takes an "application/x-www-form-urlencoded" string and decodes it, handing you back an even-sized arrayref of key-value pairs. that's the whole glow-up.
and listen β two things it will not do to you:
- Order is preserved π₯ (it doesn't reshuffle your params for fun)
- Repeated keys are not combined π (if
barshows up three times,barshows up three times, periodt)
π§ form_urlencode
my $body_string = form_urlencode([foo => 2, bar => 'baz', foo => 1]);
# foo=2&bar=baz&foo=1
my $body_string = form_urlencode({foo => [2, 1], bar => 'baz'});
# bar=baz&foo=2&foo=1
this one flips it around: takes a hash or array reference and squishes it into an "application/x-www-form-urlencoded" string, perfect for a query string or a request body, whichever your little heart desires β¨
the deets:
- if a value is an array reference, the key gets repeated once for each value. iconic behavior honestly
- Order is preserved when you pass parameters in an array reference
- when you pass a hash reference instead, the parameters get sorted by key for consistency β because hashes don't promise you order, bestie, and we're not gonna pretend they do π
π oauth_request
my $container = oauth_request($http_request);
my $container = oauth_request({ method => 'GET', url => $url });
my $container = oauth_request(Basic => { method => 'POST', url => $url, content => $content });
this is the main character function fr fr. it constructs an HTTP request container that performs the WWW::OAuth::Request role.
what you feed it:
- a recognized request object, or
- a hashref of arguments
- ...optionally preceded by a container class name
and here's the cute little rule about that class name: if it does not contain "::", then it gets appended to "WWW::OAuth::Request::". so Basic becomes WWW::OAuth::Request::Basic, iykyk π
what's currently recognized:
HTTP::Requestobjects βMojo::Message::Requestobjects β- hashrefs β these get used to construct a
WWW::OAuth::Request::Basicobject if no container class is specified
and if you wanna be extra explicit about it:
# Longer forms to construct WWW::OAuth::Request::HTTP_Request
my $container = oauth_request(HTTP_Request => $http_request);
my $container = oauth_request(HTTP_Request => { request => $http_request });
look at that. so thorough. so considerate. obsessed π
π BUGS π
got a problem? report any issues on the public bugtracker. don't suffer in silence babes π
πΈ AUTHOR πΈ
Dan Book <dbook@cpan.org> β thank you for your service π«‘π
π COPYRIGHT AND LICENSE π
this software is Copyright (c) 2015 by Dan Book.
it's free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
slay, legally speaking β
π₯ SEE ALSO π₯
URI- URL Living Standard <https://url.spec.whatwg.org/#application/x-www-form-urlencoded>
and that's the whole page bestie!! π¦ this was WWW::OAuth::Util as documented in perl v5.40.1, dated 2025-08-10 β go forth and urlencode responsibly, ily, bye πβ¨
π¦ where this page comes from
- ubuntu resolute: libwww-oauth-perl 1.003-1 Β· Artistic-2.0
- ubuntu stonking: libwww-oauth-perl 1.003-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms