| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Azure::NotificationHubs::Request; |
|
2
|
7
|
|
|
7
|
|
97778
|
use strict; |
|
|
7
|
|
|
|
|
23
|
|
|
|
7
|
|
|
|
|
138
|
|
|
3
|
7
|
|
|
7
|
|
38
|
use warnings; |
|
|
7
|
|
|
|
|
10
|
|
|
|
7
|
|
|
|
|
119
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
2004
|
use Net::Azure::NotificationHubs::Response; |
|
|
7
|
|
|
|
|
17
|
|
|
|
7
|
|
|
|
|
143
|
|
|
6
|
7
|
|
|
7
|
|
30
|
use Carp; |
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
250
|
|
|
7
|
7
|
|
|
7
|
|
798
|
use URI; |
|
|
7
|
|
|
|
|
6353
|
|
|
|
7
|
|
|
|
|
175
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
|
10
|
7
|
|
|
|
|
37
|
new => 0, |
|
11
|
|
|
|
|
|
|
rw => [qw[agent]], |
|
12
|
|
|
|
|
|
|
ro => [qw[method uri headers content]], |
|
13
|
7
|
|
|
7
|
|
26
|
); |
|
|
7
|
|
|
|
|
12
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
|
16
|
9
|
|
|
9
|
1
|
20745
|
my ($class, $method, $uri, $headers, $content) = @_; |
|
17
|
9
|
100
|
100
|
|
|
77
|
bless { |
|
18
|
|
|
|
|
|
|
method => $method, |
|
19
|
|
|
|
|
|
|
uri => ref($uri) =~ /\AURI::/ ? $uri : URI->new($uri), |
|
20
|
|
|
|
|
|
|
headers => $headers || {}, |
|
21
|
|
|
|
|
|
|
content => $content, |
|
22
|
|
|
|
|
|
|
}, $class; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub header { |
|
26
|
18
|
|
|
18
|
0
|
6632
|
my ($self, $key, $value) = @_; |
|
27
|
18
|
50
|
|
|
|
35
|
return $self->{headers} if !$key; |
|
28
|
18
|
100
|
|
|
|
36
|
if (defined $value) { |
|
29
|
4
|
|
|
|
|
5
|
$self->{headers}{$key} = $value; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
18
|
|
|
|
|
59
|
return $self->{headers}{$key}; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub do { |
|
35
|
4
|
|
|
4
|
1
|
1811
|
my $self = shift; |
|
36
|
4
|
|
|
|
|
18
|
my $options = {headers => $self->headers}; |
|
37
|
4
|
50
|
|
|
|
40
|
if ($self->content) { |
|
38
|
0
|
|
|
|
|
0
|
$options->{content} = $self->content; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
30
|
my $res = $self->agent->request($self->method, $self->uri, $options); |
|
42
|
4
|
|
|
|
|
526923
|
my $status = delete $res->{status}; |
|
43
|
4
|
|
|
|
|
14
|
my $reason = delete $res->{reason}; |
|
44
|
4
|
|
|
|
|
9
|
my $headers = delete $res->{headers}; |
|
45
|
4
|
|
|
|
|
12
|
my $content = delete $res->{content}; |
|
46
|
|
|
|
|
|
|
|
|
47
|
4
|
100
|
|
|
|
37
|
croak "$status $reason" if !$res->{success}; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Net::Azure::NotificationHubs::Response->new( |
|
50
|
|
|
|
|
|
|
$status, $reason, $headers, $content, $res->{success} |
|
51
|
3
|
|
|
|
|
39
|
); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=encoding utf-8 |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Net::Azure::NotificationHubs::Request - A Request Class for Net::Azure::NotificationHubs |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
use Net::Azure::NotificationHubs::Request; |
|
65
|
|
|
|
|
|
|
use HTTP::Tiny; |
|
66
|
|
|
|
|
|
|
my $req = Net::Azure::NotificationHubs::Request->new(GET => 'http://...'); |
|
67
|
|
|
|
|
|
|
$req->agent(HTTP::Tiny->new); |
|
68
|
|
|
|
|
|
|
my $res = $req->do; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Net::Azure::NotificationHubs::Request is a request class for Net::Azure::NotificationHubs. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 new |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
A constructor method. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 agent |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $agent = HTTP::Tiny->new(...); |
|
83
|
|
|
|
|
|
|
$req->agent($agent); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
An accessor for setting/getting a HTTP::Tiny object |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 do |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $res = $req->do; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Do itself as http/https request with agent. Then returns a response object. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 LICENSE |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Copyright (C) ytnobody. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
98
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
ytnobody Eytnobody@gmail.comE |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |