OAuth/Request.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 100% 23 / 23 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« OAuth/Request/Basic.pm ↑ Summary
1 package WWW::OAuth::Request;
2  
3 5 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use WWW::OAuth::Util 'form_urldecode';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 our $VERSION = '1.000';
9  
10 5 requires 'method', 'url', 'content', 'content_is_form', 'header', 'request_with';
11  
12 8 ▶sub query_pairs { [map { utf8::decode $_; $_ } URI->new(shift->url)->query_form] }
Subroutine query_pairs: called CC=1 SCAR=0.0
Pod documented
13  
14 6 ▶sub body_pairs { form_urldecode shift->content }
Subroutine body_pairs: called CC=1 SCAR=0.0
Pod documented
15  
16 5 1;
17  
18 =head1 NAME
19  
20 WWW::OAuth::Request - HTTP Request container role
21  
22 =head1 SYNOPSIS
23  
24 use Role::Tiny::With;
25 with 'WWW::OAuth::Request';
26  
27 =head1 DESCRIPTION
28  
29 L<WWW::OAuth::Request> is a L<Role::Tiny> role that provides a consistent
30 interface to L<WWW::OAuth> for parsing and authenticating requests. See
31 L<WWW::OAuth/"HTTP REQUEST CONTAINERS"> for specifics.
32  
33 =head1 METHODS
34  
35 L<WWW::OAuth::Request> implements or requires the following methods.
36  
37 =head2 body_pairs
38  
39 my $pairs = $req->body_pairs;
40  
41 Return body parameters from C<application/x-www-form-urlencoded> L</"content">
42 as an even-sized arrayref of keys and values.
43  
44 =head2 content
45  
46 my $content = $req->content;
47 $req = $req->content('foo=1&baz=2');
48  
49 Set or return request content. Must be implemented to compose role.
50  
51 =head2 content_is_form
52  
53 my $bool = $req->content_is_form;
54  
55 Check whether content is single-part and content type is
56 C<application/x-www-form-urlencoded>. Must be implemented to compose role.
57  
58 =head2 header
59  
60 my $header = $req->header('Content-Type');
61 $req = $req->header('Content-Type' => 'application/x-www-form-urlencoded');
62  
63 Set or return a request header. Multiple values can be set by passing an array
64 reference as the value, and multi-value headers are joined on C<, > when
65 returned. Must be implemented to compose role.
66  
67 =head2 method
68  
69 my $method = $req->method;
70 $req = $req->method('GET');
71  
72 Set or return request method. Must be implemented to compose role.
73  
74 =head2 query_pairs
75  
76 my $pairs = $req->query_pairs;
77  
78 Return query parameters from L</"url"> as an even-sized arrayref of keys and
79 values.
80  
81 =head2 request_with
82  
83 my $res = $req->request_with($ua);
84  
85 Send request using passed user-agent object, and return response. Must be
86 implemented to compose role.
87  
88 =head2 url
89  
90 my $url = $req->url;
91 $req = $req->url('http://example.com/api/');
92  
93 Set or return request URL. Must be implemented to compose role.
94  
95 =head1 BUGS
96  
97 Report any issues on the public bugtracker.
98  
99 =head1 AUTHOR
100  
101 Dan Book <dbook@cpan.org>
102  
103 =head1 COPYRIGHT AND LICENSE
104  
105 This software is Copyright (c) 2015 by Dan Book.
106  
107 This is free software, licensed under:
108  
109 The Artistic License 2.0 (GPL Compatible)
110  
111 =head1 SEE ALSO
112  
113 L<HTTP::Request>, L<Mojo::Message::Request>
« OAuth/Request/Basic.pm ↑ Summary