line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Engine::Request::Upload; |
2
|
1
|
|
|
1
|
|
4
|
use Any::Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
has filename => ( |
4
|
|
|
|
|
|
|
is => 'ro', |
5
|
|
|
|
|
|
|
); |
6
|
|
|
|
|
|
|
has headers => ( |
7
|
|
|
|
|
|
|
is => 'ro', |
8
|
|
|
|
|
|
|
handles => { |
9
|
|
|
|
|
|
|
type => 'content_type' |
10
|
|
|
|
|
|
|
}, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
has size => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
has tempname => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
has basename => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
lazy => 1, |
21
|
|
|
|
|
|
|
default => sub { |
22
|
|
|
|
|
|
|
my $self = shift; |
23
|
|
|
|
|
|
|
require File::Spec::Unix; |
24
|
|
|
|
|
|
|
my $basename = $self->filename; |
25
|
|
|
|
|
|
|
$basename =~ s|\\|/|g; |
26
|
|
|
|
|
|
|
$basename = ( File::Spec::Unix->splitpath($basename) )[2]; |
27
|
|
|
|
|
|
|
$basename =~ s|[^\w\.-]+|_|g; |
28
|
|
|
|
|
|
|
$basename; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has fh => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
lazy => 1, |
35
|
|
|
|
|
|
|
default => sub { |
36
|
|
|
|
|
|
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
open my $fh, '<', $self->tempname or die "Can't open '@{[ $self->tempname ]}': '$!'"; |
39
|
|
|
|
|
|
|
return $fh; |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub copy_to { |
44
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
45
|
0
|
|
|
|
|
|
require File::Copy; |
46
|
0
|
|
|
|
|
|
File::Copy::copy( $self->tempname, @_ ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub link_to { |
50
|
0
|
|
|
0
|
1
|
|
my ( $self, $target ) = @_; |
51
|
0
|
|
|
|
|
|
CORE::link( $self->tempname, $target ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub slurp { |
55
|
0
|
|
|
0
|
1
|
|
my ( $self, $layer ) = @_; |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
$layer = ':raw' unless $layer; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $content = undef; |
60
|
0
|
|
|
|
|
|
my $handle = $self->fh; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
binmode( $handle, $layer ); |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
while ( $handle->read( my $buffer, 8192 ) ) { |
65
|
0
|
|
|
|
|
|
$content .= $buffer; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$content; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
1
|
|
771
|
no Any::Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
72
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(inline_destructor => 1); |
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
__END__ |