line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::EveOnline::EveCentral::HTTPRequest; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Games::EveOnline::EveCentral::HTTPRequest::VERSION = '0.001'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
40212
|
use Moo 1.003001; |
|
7
|
|
|
|
|
17776
|
|
|
7
|
|
|
|
|
45
|
|
7
|
7
|
|
|
7
|
|
5500
|
use MooX::Types::MooseLike 0.25; |
|
7
|
|
|
|
|
2802
|
|
|
7
|
|
|
|
|
479
|
|
8
|
7
|
|
|
7
|
|
954
|
use MooX::StrictConstructor 0.006; |
|
7
|
|
|
|
|
13065
|
|
|
7
|
|
|
|
|
42
|
|
9
|
7
|
|
|
7
|
|
29659
|
use MooX::Types::MooseLike::Base qw(AnyOf ArrayRef Enum HashRef Str Undef); |
|
7
|
|
|
|
|
5494
|
|
|
7
|
|
|
|
|
643
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Internal use class to create HTTP::Request objects. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
7
|
|
|
7
|
|
133
|
use 5.012; |
|
7
|
|
|
|
|
101
|
|
|
7
|
|
|
|
|
251
|
|
16
|
|
|
|
|
|
|
|
17
|
7
|
|
|
7
|
|
6906
|
use HTTP::Request 6.0; |
|
7
|
|
|
|
|
169201
|
|
|
7
|
|
|
|
|
270
|
|
18
|
7
|
|
|
7
|
|
65
|
use HTTP::Headers 6.05; |
|
7
|
|
|
|
|
169
|
|
|
7
|
|
|
|
|
177
|
|
19
|
7
|
|
|
7
|
|
859
|
use Readonly 1.03; |
|
7
|
|
|
|
|
3414
|
|
|
7
|
|
|
|
|
445
|
|
20
|
7
|
|
|
7
|
|
34
|
use URI::Escape 3.31 qw(uri_escape_utf8); |
|
7
|
|
|
|
|
120
|
|
|
7
|
|
|
|
|
2887
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Readonly::Scalar my $BASE_URL => "http://api.eve-central.com/api"; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'method' => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => Enum['GET', 'POST'], |
28
|
|
|
|
|
|
|
required => 1 |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has 'path' => ( |
32
|
|
|
|
|
|
|
is => 'ro', |
33
|
|
|
|
|
|
|
isa => Str, |
34
|
|
|
|
|
|
|
required => 1 |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has 'headers' => ( |
38
|
|
|
|
|
|
|
is => 'ro', |
39
|
|
|
|
|
|
|
isa => HashRef, |
40
|
|
|
|
|
|
|
default => sub { {} } |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has 'content' => ( |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
isa => AnyOf[ArrayRef[Str], Undef], |
46
|
|
|
|
|
|
|
default => sub { [] } |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub http_request { |
52
|
7
|
|
|
7
|
1
|
1897
|
my $self = shift; |
53
|
7
|
|
|
|
|
37
|
my $method = $self->method; |
54
|
7
|
|
|
|
|
52
|
my $path = $self->_urlencode($self->path); |
55
|
7
|
|
|
|
|
1620
|
my $headers = $self->_create_headers($self->headers); |
56
|
7
|
|
|
|
|
38
|
my $content = $self->content; |
57
|
|
|
|
|
|
|
|
58
|
7
|
|
|
|
|
27
|
my $uri = "$BASE_URL/$path"; |
59
|
7
|
|
|
|
|
63
|
my $request = HTTP::Request->new($method, $uri, $headers, $content); |
60
|
|
|
|
|
|
|
|
61
|
7
|
|
|
|
|
73455
|
return $request; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _urlencode { |
66
|
7
|
|
|
7
|
|
20
|
my ($self, $unencoded) = @_; |
67
|
7
|
|
|
|
|
51
|
return uri_escape_utf8($unencoded, '^A-Za-z0-9_-'); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _create_headers { |
72
|
7
|
|
|
7
|
|
19
|
my ($self, $headers) = @_; |
73
|
7
|
|
|
|
|
81
|
my $http_headers = HTTP::Headers->new; |
74
|
|
|
|
|
|
|
|
75
|
7
|
|
|
|
|
128
|
while ( my ( $k, $v ) = each %$headers ) { |
76
|
1
|
|
|
|
|
7
|
$http_headers->header( $k => $v ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
7
|
|
|
|
|
102
|
return $http_headers; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; # End of Games::EveOnline::EveCentral::HTTPRequest |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=pod |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 NAME |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Games::EveOnline::EveCentral::HTTPRequest - Internal use class to create HTTP::Request objects. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 VERSION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
version 0.001 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SYNOPSIS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $http_request = Games::EveOnline::EveCentral::HTTPRequest->new( |
100
|
|
|
|
|
|
|
method => 'GET', # or 'POST' |
101
|
|
|
|
|
|
|
path => $api_method, |
102
|
|
|
|
|
|
|
headers => $headers, |
103
|
|
|
|
|
|
|
content => $content # if using POST, [] |
104
|
|
|
|
|
|
|
)->http_request; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 DESCRIPTION |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This module creates an HTTP::Request object to make the API call with. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=for test_synopsis no strict 'vars' |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 METHODS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 http_request |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This method creates an HTTP::Request object. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=begin private |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 _urlencode |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
URL-encode a given path. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 _create_headers |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Create an HTTP::Headers object from a hash. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=end private |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHOR |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Pedro Figueiredo, C<< <me at pedrofigueiredo.org> >> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 BUGS |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Please report any bugs or feature requests through the web interface at |
139
|
|
|
|
|
|
|
L<https://github.com/pfig/games-eveonline-evecentral/issues>. I will be |
140
|
|
|
|
|
|
|
notified, and then you'll automatically be notified of progress on your bug as |
141
|
|
|
|
|
|
|
I make changes. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SUPPORT |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
perldoc Games::EveOnline::EveCentral |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
You can also look for information at: |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over 4 |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * GitHub Issues (report bugs here) |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L<https://github.com/pfig/games-eveonline-evecentral/issues> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Games-EveOnline-EveCentral> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * CPAN Ratings |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Games-EveOnline-EveCentral> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * CPAN |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L<http://metacpan.org/module/Games::EveOnline::EveCentral> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=back |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=over 4 |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * The people behind EVE Central. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
L<http://eve-central.com/> |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=back |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Copyright 2013 Pedro Figueiredo. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
186
|
|
|
|
|
|
|
under the terms of the Artistic License. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 AUTHOR |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Pedro Figueiredo <me@pedrofigueiredo.org> |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Pedro Figueiredo. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
199
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |