| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Plugin::SwiffUploaderCookieHack; |
|
2
|
1
|
|
|
1
|
|
1169884
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
3712355
|
|
|
|
1
|
|
|
|
|
8
|
|
|
3
|
1
|
|
|
1
|
|
1426
|
use Moose::Role; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use MooseX::Mangle; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use CGI::Simple::Cookie (); |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
mangle_return 'prepare' => sub { |
|
11
|
|
|
|
|
|
|
my ($class, $c) = @_; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $cookie_name = $c->_session_plugin_config->{cookie_name}; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
if ( my $sid = $c->req->params->{$cookie_name} ) { |
|
16
|
|
|
|
|
|
|
$c->log->debug('fixing Swiff.Uploader cookie'); |
|
17
|
|
|
|
|
|
|
$c->request->cookies->{$cookie_name} = CGI::Simple::Cookie->new( |
|
18
|
|
|
|
|
|
|
-name => $cookie_name, |
|
19
|
|
|
|
|
|
|
-value => $sid, |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return $c; |
|
24
|
|
|
|
|
|
|
}; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Catalyst::Plugin::SwiffUploaderCookieHack - Hack to get session restored when |
|
31
|
|
|
|
|
|
|
Flash makes a HTTP request to your app. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
There is a major deficiency in the Flash http client. A sane browser plugin |
|
36
|
|
|
|
|
|
|
would collect cookies that exist in the context it was loaded from and include |
|
37
|
|
|
|
|
|
|
those cookies in the headers of any http requests it makes. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Flash dosen't always do this, and in the situations where it does the |
|
40
|
|
|
|
|
|
|
implementation is not optimal. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
To work around this, on the client side add your L<Catalyst::Plugin::Session::State::Cookie>'s |
|
43
|
|
|
|
|
|
|
session id to the body of the http request keyed to your session's cookie name |
|
44
|
|
|
|
|
|
|
and use this plugin to get the session seamlessly restored. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 USAGE |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
FancyUpload knows about this problem and will put cookies in the http request |
|
49
|
|
|
|
|
|
|
for you when it uploads a file if you ask it to. See the appendCookieData |
|
50
|
|
|
|
|
|
|
option at L<http://digitarald.de/project/fancyupload/>. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Then load this plugin in to Catalyst like so: |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
use Catalyst ( |
|
55
|
|
|
|
|
|
|
... |
|
56
|
|
|
|
|
|
|
'SwiffUploaderCookieHack', |
|
57
|
|
|
|
|
|
|
... |
|
58
|
|
|
|
|
|
|
'Session', |
|
59
|
|
|
|
|
|
|
'Session::Store::DBIC', |
|
60
|
|
|
|
|
|
|
'Session::State::Cookie', |
|
61
|
|
|
|
|
|
|
... |
|
62
|
|
|
|
|
|
|
); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Now your session will work seamlessly with Flash. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 CAVEATS |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
If you try to use the app's L<Catalyst::Plugin::Session> before this plugin |
|
69
|
|
|
|
|
|
|
runs, things aren't going to work. Try to reference it in the front of the |
|
70
|
|
|
|
|
|
|
C<use Catalyst(...)> argument list so it runs early. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 AUTHOR |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Todd Wade <waveright@gmail.com> |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Copyright 2010 Todd Wade |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This sofware is free software, and is licensed under the same terms as perl itself. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
|
83
|
|
|
|
|
|
|
|