line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Engine::Request::Upload; |
2
|
57
|
|
|
57
|
|
1562
|
use Any::Moose; |
|
57
|
|
|
|
|
128
|
|
|
57
|
|
|
|
|
537
|
|
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
|
1
|
|
|
1
|
1
|
487
|
my $self = shift; |
45
|
1
|
|
|
|
|
3271
|
require File::Copy; |
46
|
1
|
|
|
|
|
5933
|
File::Copy::copy( $self->tempname, @_ ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub link_to { |
50
|
1
|
|
|
1
|
1
|
36
|
my ( $self, $target ) = @_; |
51
|
1
|
|
|
|
|
81
|
CORE::link( $self->tempname, $target ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub slurp { |
55
|
11
|
|
|
11
|
1
|
78
|
my ( $self, $layer ) = @_; |
56
|
|
|
|
|
|
|
|
57
|
11
|
100
|
|
|
|
47
|
$layer = ':raw' unless $layer; |
58
|
|
|
|
|
|
|
|
59
|
11
|
|
|
|
|
23
|
my $content = undef; |
60
|
11
|
|
|
|
|
83
|
my $handle = $self->fh; |
61
|
|
|
|
|
|
|
|
62
|
11
|
|
|
|
|
74
|
binmode( $handle, $layer ); |
63
|
|
|
|
|
|
|
|
64
|
11
|
|
|
|
|
86
|
while ( $handle->read( my $buffer, 8192 ) ) { |
65
|
11
|
|
|
|
|
328
|
$content .= $buffer; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
11
|
|
|
|
|
129
|
$content; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
57
|
|
|
57
|
|
70602
|
no Any::Moose; |
|
57
|
|
|
|
|
148
|
|
|
57
|
|
|
|
|
339
|
|
72
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(inline_destructor => 1); |
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
__END__ |