line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Smoke::Poster::HTTP_Tiny; |
2
|
4
|
|
|
4
|
|
28
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
154
|
|
3
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
143
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
57
|
use base 'Test::Smoke::Poster::Base'; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
523
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
29
|
use URI::Escape qw(uri_escape); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1490
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Test::Smoke::Poster::HTTP_Tiny - Poster subclass using HTTP::Tiny. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This is a subclass of L. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 Test::Smoke::Poster::HTTP_Tiny->new(%arguments) |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head3 Extra Arguments |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
None. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
5
|
|
|
5
|
1
|
26
|
my $class = shift; |
29
|
5
|
|
|
|
|
125
|
my $self = $class->SUPER::new(@_); |
30
|
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
42
|
require HTTP::Tiny; |
32
|
5
|
100
|
|
|
|
52
|
$self->{_ua} = HTTP::Tiny->new( |
33
|
|
|
|
|
|
|
agent => $self->agent_string(), |
34
|
|
|
|
|
|
|
( $self->ua_timeout ? (timeout => $self->ua_timeout) : () ), |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
5
|
|
|
|
|
543
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 $poster->_post_data() |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Post the json to CoreSmokeDB using HTTP::Tiny. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _post_data { |
47
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
12
|
$self->log_info("Posting to %s via %s.", $self->smokedb_url, $self->poster); |
50
|
1
|
|
|
|
|
7
|
$self->log_debug("Report data: %s", my $json = $self->get_json); |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
30
|
my $form_data = sprintf("json=%s", uri_escape($json)); |
53
|
1
|
|
|
|
|
100
|
my $response = $self->ua->request( |
54
|
|
|
|
|
|
|
POST => $self->smokedb_url, |
55
|
|
|
|
|
|
|
{ |
56
|
|
|
|
|
|
|
headers => { |
57
|
|
|
|
|
|
|
'Content-Type' => 'application/x-www-form-urlencoded', |
58
|
|
|
|
|
|
|
'Content-Length' => length($form_data), |
59
|
|
|
|
|
|
|
}, |
60
|
|
|
|
|
|
|
content => $form_data, |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
1
|
50
|
|
|
|
5418
|
if (!$response->{success}) { |
65
|
|
|
|
|
|
|
$self->log_warn( |
66
|
|
|
|
|
|
|
"POST failed: %s %s%s", |
67
|
|
|
|
|
|
|
$response->{status}, |
68
|
|
|
|
|
|
|
$response->{reason}, |
69
|
0
|
0
|
|
|
|
0
|
($response->{content} ? " ($response->{content})" : ""), |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
die sprintf( |
72
|
|
|
|
|
|
|
"POST to '%s' failed: %s %s%s\n", |
73
|
|
|
|
|
|
|
$self->smokedb_url, |
74
|
|
|
|
|
|
|
$response->{status}, $response->{reason}, |
75
|
0
|
0
|
|
|
|
0
|
($response->{content} ? " ($response->{content})" : ""), |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
6
|
$self->log_debug("[CoreSmokeDB] %s", $response->{content}); |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
8
|
return $response->{content}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 COPYRIGHT |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
(c) 2002-2013, Abe Timmerman All rights reserved. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
With contributions from Jarkko Hietaniemi, Merijn Brand, Campo |
91
|
|
|
|
|
|
|
Weijerman, Alan Burlison, Allen Smith, Alain Barbet, Dominic Dunlop, |
92
|
|
|
|
|
|
|
Rich Rauenzahn, David Cantrell. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
95
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
See: |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 4 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * L |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * L |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
108
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
109
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |