NAME
WWW::OAuth::Request::Basic - HTTP Request container for HTTP::Tiny
SYNOPSIS
my $req = WWW::OAuth::Request::Basic->new(method => 'POST', url => $url, content => $content);
$req->request_with(HTTP::Tiny->new);
DESCRIPTION
WWW::OAuth::Request::Basic is a request container for WWW::OAuth that stores the request parameters directly, for use with user-agents that do not use request objects like HTTP::Tiny. It performs the role WWW::OAuth::Request.
ATTRIBUTES
WWW::OAuth::Request::Basic implements the following attributes.
content
my $content = $req->content;
$req = $req->content('foo=1&bar=2');
Request content string.
headers
my $headers = $req->headers;
$req = $req->headers({});
Hashref of request headers. Must be updated carefully as headers are case-insensitive. Values can be array references to specify multi-value headers.
method
my $method = $req->method;
$req = $req->method('GET');
Request method.
url
my $url = $req->url;
$req = $req->url('http://example.com/api/');
Request URL.
METHODS
WWW::OAuth::Request::Basic composes all methods from WWW::OAuth::Request, and implements the following new ones.
content_is_form
my $bool = $req->content_is_form;
Check whether "headers" contains a Content-Type
header set to application/x-www-form-urlencoded
.
header
my $header = $req->header('Content-Type');
$req = $req->header(Authorization => 'Basic foobar');
Set or return a request header in "headers".
set_form
$req = $req->set_form({foo => 'bar'});
Convenience method to set "content" to a urlencoded form. Equivalent to:
use WWW::OAuth::Util 'form_urlencode';
$req->header('Content-Type' => 'application/x-www-form-urlencoded');
$req->content(form_urlencode $form);
request_with
my $res = $req->request_with(HTTP::Tiny->new);
Run request with passed HTTP::Tiny user-agent object, and return response hashref, as in "request" in HTTP::Tiny.
BUGS
Report any issues on the public bugtracker.
AUTHOR
Dan Book <dbook@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2015 by Dan Book.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)