line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Plugin::EmptyGIF; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Dancer::Plugin::EmptyGIF - Quick empty GIF response |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Dancer; |
10
|
|
|
|
|
|
|
use Dancer::Plugin::EmptyGIF; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
get '/tracking/pixel.gif' => sub { |
13
|
|
|
|
|
|
|
# do something with params |
14
|
|
|
|
|
|
|
return empty_gif; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 METHODS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 empty_gif |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This will set your set your current request response to be an empty |
22
|
|
|
|
|
|
|
gif, this means, it will return binary data for the image and |
23
|
|
|
|
|
|
|
set the appropriate headers. You should always "return empty_gif". |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 WHY |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
An empty gif response is specially useful when you're building a |
28
|
|
|
|
|
|
|
webservice that processes all the URL and/or query string parameters |
29
|
|
|
|
|
|
|
and at the end, an empty gif needs to be returned to the client. |
30
|
|
|
|
|
|
|
This a tracking or reporting pixel. Once the request has reached your |
31
|
|
|
|
|
|
|
application code, it's better not to do any more redirections and |
32
|
|
|
|
|
|
|
quickly return the empty pixel from within your code. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 AUTHOR |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
David Moreno C<< >> |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 CODE |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
L |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 LICENSE |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Copyright, David Moreno, 2012 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This program is free software; you can redistribute it |
47
|
|
|
|
|
|
|
and/or modify it under the same terms as Perl itself. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
4
|
|
|
4
|
|
1124093
|
use Dancer ':syntax'; |
|
4
|
|
|
|
|
391307
|
|
|
4
|
|
|
|
|
23
|
|
52
|
4
|
|
|
4
|
|
5447
|
use Dancer::Plugin; |
|
4
|
|
|
|
|
5947
|
|
|
4
|
|
|
|
|
334
|
|
53
|
4
|
|
|
4
|
|
5131
|
use MIME::Base64; |
|
4
|
|
|
|
|
3510
|
|
|
4
|
|
|
|
|
2422
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
our $VERSION = '0.3'; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
register empty_gif => sub { |
58
|
4
|
|
|
4
|
|
8874
|
header('Content-Type' => 'image/gif'); |
59
|
4
|
|
|
|
|
205
|
header('Content-Disposition' => 'inline; filename="empty.gif"'); |
60
|
4
|
|
|
|
|
280
|
decode_base64('R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='); |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
register_plugin; |
64
|
|
|
|
|
|
|
1; |