line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Shorten::UserAgent; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
44
|
use strict; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
178
|
|
4
|
7
|
|
|
7
|
|
29
|
use warnings; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
194
|
|
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
36
|
use base 'LWP::UserAgent'; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
4677
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '3.094'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub get { |
11
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
12
|
0
|
|
|
|
|
|
my $resp = $self->SUPER::get(@_); |
13
|
|
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
|
die $resp->status_line if $resp->is_error; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
return $resp; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub post { |
20
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
21
|
0
|
|
|
|
|
|
my $resp = $self->SUPER::post(@_); |
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
die $resp->status_line if $resp->is_error; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
return $resp; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
WWW::Shorten::UserAgent - LWP::UserAgent subclass for WWW::Shorten modules. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use strict; |
37
|
|
|
|
|
|
|
use warnings; |
38
|
|
|
|
|
|
|
use WWW::Shorten::UserAgent; |
39
|
|
|
|
|
|
|
use Try::Tiny qw(try catch); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $ua = WWW::Shorten::UserAgent->new; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $resp = try { |
44
|
|
|
|
|
|
|
$ua->get($url); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
catch { |
47
|
|
|
|
|
|
|
warn "Uh oh: $_"; |
48
|
|
|
|
|
|
|
return undef; |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Subclass of LWP::UserAgent which works the same way as the superclass |
54
|
|
|
|
|
|
|
except that it throws an exception if the C or C method returns |
55
|
|
|
|
|
|
|
an error. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
See L for the full documentation. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 METHODS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 get |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Makes an HTTP GET request and throws an exception on error. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 post |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Makes an HTTP POST request and throws an exception on error. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Dave Cross |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Copyright (c) Magnum Solutions Ltd., 2012. All rights reserved. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This module is free software. You can redistribute it and/or |
78
|
|
|
|
|
|
|
modify it under the terms of the Artistic License 2.0. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
81
|
|
|
|
|
|
|
but without any warranty; without even the implied warranty of |
82
|
|
|
|
|
|
|
merchantability or fitness for a particular purpose. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SEE ALSO |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |