line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Faker::Plugin::HttpUserAgent; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
37721
|
use 5.018; |
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Venus::Class 'base'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
base 'Faker::Plugin'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
736
|
use POSIX 'strftime'; |
|
1
|
|
|
|
|
6496
|
|
|
1
|
|
|
|
|
5
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# METHODS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub execute { |
21
|
3
|
|
|
3
|
1
|
1100
|
my ($self, $data) = @_; |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
13
|
my $faker = $self->faker; |
24
|
3
|
|
|
|
|
1466
|
my $random = $faker->random; |
25
|
3
|
|
|
|
|
7
|
my $class = 'Mozilla'; |
26
|
3
|
|
|
|
|
12
|
my $version = join '.', $random->range(5, 9), $random->range(0, 9); |
27
|
3
|
|
|
|
|
99
|
my $product = join '/', $class, $version; |
28
|
3
|
|
|
|
|
200
|
my $this_year = strftime '%Y', localtime; |
29
|
3
|
|
|
|
|
25
|
my $rand_year = $random->select([($this_year-20)..$this_year]); |
30
|
3
|
|
|
|
|
90
|
my $rand_month = sprintf('%.2d', $random->range(1, 12)); |
31
|
3
|
|
|
|
|
60
|
my $rand_day = sprintf('%.2d', $random->range(1, 28)); |
32
|
3
|
|
|
|
|
52
|
my $engine = join '/', 'Gecko', join('', $rand_year, $rand_month, $rand_day); |
33
|
3
|
|
|
|
|
25
|
my $platform = $random->select([ |
34
|
|
|
|
|
|
|
['Macintosh', ['Mac OS ##.#', 'Max OS X ##.#'], ['Chrome', 'Safari']], |
35
|
|
|
|
|
|
|
['Windows', ['Windows ##.#', 'Windows NT ##.#'], ['Chrome', 'Edge', 'Firefox']], |
36
|
|
|
|
|
|
|
['X11', ['Linux x86', 'Linux x86_64'], ['Chrome', 'Firefox']], |
37
|
|
|
|
|
|
|
]); |
38
|
3
|
|
|
|
|
84
|
my $locale = $random->select([ |
39
|
|
|
|
|
|
|
'cs-CZ', |
40
|
|
|
|
|
|
|
'da-DK', |
41
|
|
|
|
|
|
|
'de-DE', |
42
|
|
|
|
|
|
|
'en-GB', |
43
|
|
|
|
|
|
|
'en-US', |
44
|
|
|
|
|
|
|
'es-ES', |
45
|
|
|
|
|
|
|
'ja-JP', |
46
|
|
|
|
|
|
|
'nb-NO', |
47
|
|
|
|
|
|
|
'pl-PL', |
48
|
|
|
|
|
|
|
'pt-BR', |
49
|
|
|
|
|
|
|
'sv-SE', |
50
|
|
|
|
|
|
|
'tr-TR', |
51
|
|
|
|
|
|
|
'zh-CN', |
52
|
|
|
|
|
|
|
'zh-TW', |
53
|
|
|
|
|
|
|
]); |
54
|
3
|
|
|
|
|
101
|
my $software = join ':', 'rv', $faker->software_version; |
55
|
3
|
|
|
|
|
280
|
my $os_name = $platform->[0]; |
56
|
3
|
|
|
|
|
229
|
my $os_desc = $self->process_markers( |
57
|
|
|
|
|
|
|
$self->process_format($random->select($platform->[1])) |
58
|
|
|
|
|
|
|
); |
59
|
3
|
|
|
|
|
15
|
my $comment = sprintf('(%s)', join('; ', $os_name, 'U', $os_desc, $software)); |
60
|
3
|
|
|
|
|
9
|
my $client = $random->select($platform->[2]); |
61
|
3
|
|
|
|
|
87
|
my $client_version = $faker->software_version; |
62
|
3
|
|
|
|
|
228
|
my $user_agent = "$product $comment $engine $os_name $client/$client_version"; |
63
|
|
|
|
|
|
|
|
64
|
3
|
|
|
|
|
135
|
return $user_agent; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Faker::Plugin::HttpUserAgent - HTTP User-Agent |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 ABSTRACT |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
HTTP User-Agent for Faker |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 VERSION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1.19 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SYNOPSIS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
package main; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
use Faker::Plugin::HttpUserAgent; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $plugin = Faker::Plugin::HttpUserAgent->new; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# bless(..., "Faker::Plugin::HttpUserAgent") |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 DESCRIPTION |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This package provides methods for generating fake data for HTTP user-agents. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=encoding utf8 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 INHERITS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This package inherits behaviors from: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 METHODS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This package provides the following methods: |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 execute |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
execute(HashRef $data) (Str) |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
The execute method returns a returns a random fake HTTP user-agent. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
I> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over 4 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item execute example 1 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
package main; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
use Faker::Plugin::HttpUserAgent; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my $plugin = Faker::Plugin::HttpUserAgent->new; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# bless(..., "Faker::Plugin::HttpUserAgent") |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# my $result = $plugin->execute; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# "Mozilla/6.1 (Windows; U; Windows NT 07.6; rv:0.4.5) ... Windows Firefox/4.4.3"; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# my $result = $plugin->execute; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# "Mozilla/5.8 (Macintosh; U; Mac OS 58.2; rv:0.02) ... Macintosh Safari/0.5"; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# my $result = $plugin->execute; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# "Mozilla/9.9 (Macintosh; U; Mac OS 58.9; rv:1.25) ... Macintosh Safari/0.6"; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=back |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 new |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
new(HashRef $data) (Plugin) |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
The new method returns a new instance of the class. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
I> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=over 4 |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item new example 1 |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
package main; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
use Faker::Plugin::HttpUserAgent; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
my $plugin = Faker::Plugin::HttpUserAgent->new; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# bless(..., "Faker::Plugin::HttpUserAgent") |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=back |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 AUTHORS |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Awncorp, C |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 LICENSE |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
194
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |