WWW::O...Request(3pm)

πŸ“¦
version 1.003 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

✨ NAME ✨

WWW::OAuth::Request::HTTP_Request β€” it's the HTTP Request container for HTTP::Request, bestie πŸ’–

Like, it's the little wrapper that holds your HTTP::Request so WWW::OAuth can do its thing. iykyk.


πŸ¦‹ SYNOPSIS πŸ¦‹

my $req = WWW::OAuth::Request::HTTP_Request->new(request => $http_request);
$req->request_with(LWP::UserAgent->new);

literally two lines and you're done, we love a low-effort slay πŸ’…


🌸 DESCRIPTION 🌸

okay so WWW::OAuth::Request::HTTP_Request is a request container for WWW::OAuth β€” it wraps an HTTP::Request object πŸŽ€

and the reason that's iconic is that a bunch of different user-agents can use it: LWP::UserAgent, HTTP::Thin, and Net::Async::HTTP all play nice with it 🫢

it performs the role WWW::OAuth::Request. that's its whole job. it shows up, does the role, serves. main character energy fr fr πŸ‘‘


πŸ’– ATTRIBUTES πŸ’–

WWW::OAuth::Request::HTTP_Request implements the following attributes. yes bestie, there's only one, and it's a good one ⭐

πŸ“ request

my $http_request = $req->request;
$req             = $req->request(HTTP::Request->new(GET => $url));

the HTTP::Request object that we're gonna authenticate 🌈 that's it, that's the attribute, it's giving "small but mighty" πŸ’œ


🧚 METHODS 🧚

WWW::OAuth::Request::HTTP_Request composes all the methods from WWW::OAuth::Request (so you get those for free, no cap) and then implements the following new ones ✨

πŸ’… content

my $content = $req->content;
$req        = $req->content('foo=1&bar=2');

set or return the request content from "request" πŸ“¦ yes, the quotes around request are on purpose, it's referring to that attribute up there, we're being precise about it.

🌟 content_is_form

my $bool = $req->content_is_form;

checks whether "request" has single-part content AND a Content-Type header of application/x-www-form-urlencoded πŸ‘€

so like, it's a yes/no vibe check on whether this thing is form-encoded. returns a bool. cute πŸŽ€

my $header = $req->header('Content-Type');
$req       = $req->header(Authorization => 'Basic foobar');

set or return a request header from "request" πŸ“¬ like, get one, or set one, your call bestie.

πŸ‘‘ method

my $method = $req->method;
$req       = $req->method('GET');

set or return the request method from "request" πŸ› οΈ GET, POST, whatever you're feeling, it's your moment.

πŸ”₯ request_with

$http_response = $req->request_with(LWP::UserAgent->new);

okay this one is the actual moment β€” it runs the request with the user-agent object you pass in, and returns an HTTP::Response object πŸŽ‰

the user-agent may be LWP::UserAgent, HTTP::Thin, or Net::Async::HTTP 🫢

⚠️ heads up bestie, there's a lil plot twist: if you run it with Net::Async::HTTP, the return value is a Future yielding the HTTP::Response object β€” same as in "do_request" in Net::Async::HTTP 😭 so don't just go grabbing the response off it directly, okay? async said "not today".

🌈 url

my $url = $req->url;
$req    = $req->url('http://example.com/api/');

set or return the request URL from "request" πŸ”— where are we going? you decide.


πŸ’€ BUGS πŸ’€

report any issues on the public bugtracker πŸ™ˆ (please be nice, Dan is one person and he's doing great)


🌸 AUTHOR 🌸

Dan Book <dbook@cpan.org> πŸ’Œ


this software is Copyright (c) 2015 by Dan Book.

this is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

slay, it's free, go wild but legally πŸ’œ


⭐ SEE ALSO ⭐

  • LWP::UserAgent
  • HTTP::Thin
  • Net::Async::HTTP

and that's the whole page bestie!! 🌸 this one came from the Perl docs β€” perl v5.40.1, dated 2025-08-10 🫢 go forth and authenticate your requests, you absolute icon πŸ‘‘πŸ’–βœ¨

πŸ“¦ where this page comes from