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