line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Body::XFormsMultipart; |
2
|
|
|
|
|
|
|
$HTTP::Body::XFormsMultipart::VERSION = '1.22'; |
3
|
8
|
|
|
8
|
|
38
|
use strict; |
|
8
|
|
|
|
|
26
|
|
|
8
|
|
|
|
|
286
|
|
4
|
8
|
|
|
8
|
|
34
|
use base 'HTTP::Body::MultiPart'; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
662
|
|
5
|
8
|
|
|
8
|
|
49
|
use bytes; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
45
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
180
|
use IO::File; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
1163
|
|
8
|
8
|
|
|
8
|
|
38
|
use File::Temp 0.14; |
|
8
|
|
|
|
|
141
|
|
|
8
|
|
|
|
|
2828
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
HTTP::Body::XFormsMultipart - HTTP Body XForms multipart/related submission Parser |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use HTTP::Body::XForms; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
HTTP Body XForms submission Parser. Inherits HTTP::Body::MultiPart. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This body type is used to parse XForms submission. In this case, the |
23
|
|
|
|
|
|
|
XML part that contains the model is indicated by the start attribute |
24
|
|
|
|
|
|
|
in the content-type. The XML content is stored unparsed on the |
25
|
|
|
|
|
|
|
parameter XForms:Model. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=over 4 |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item init |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
This function is overridden to detect the start part of the |
34
|
|
|
|
|
|
|
multipart/related post. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub init { |
39
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
40
|
1
|
|
|
|
|
14
|
$self->SUPER::init(@_); |
41
|
1
|
50
|
|
|
|
4
|
unless ( $self->content_type =~ /start=\"?\([^\"\>;,]+)\>?\"?/ ) { |
42
|
0
|
|
|
|
|
0
|
my $content_type = $self->content_type; |
43
|
0
|
|
|
|
|
0
|
Carp::croak( "Invalid boundary in content_type: '$content_type'" ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
5
|
$self->{start} = $1; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
6
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item start |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Defines the start part of the multipart/related body. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub start { |
58
|
4
|
|
|
4
|
1
|
23
|
return shift->{start}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item handler |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This function is overridden to differ the start part, which should be |
64
|
|
|
|
|
|
|
set as the XForms:Model param if its content type is application/xml. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub handler { |
69
|
3
|
|
|
3
|
1
|
5
|
my ( $self, $part ) = @_; |
70
|
|
|
|
|
|
|
|
71
|
3
|
|
|
|
|
8
|
my $contentid = $part->{headers}{'Content-ID'}; |
72
|
3
|
|
|
|
|
15
|
$contentid =~ s/^.*[\<\"]//; |
73
|
3
|
|
|
|
|
22
|
$contentid =~ s/[\>\"].*$//; |
74
|
|
|
|
|
|
|
|
75
|
3
|
100
|
|
|
|
9
|
if ( $contentid eq $self->start ) { |
|
|
50
|
|
|
|
|
|
76
|
1
|
|
|
|
|
3
|
$part->{name} = 'XForms:Model'; |
77
|
1
|
50
|
|
|
|
9
|
if ($part->{done}) { |
78
|
1
|
|
|
|
|
14
|
$self->body($part->{data}); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
elsif ( defined $contentid ) { |
82
|
2
|
|
|
|
|
4
|
$part->{name} = $contentid; |
83
|
2
|
|
|
|
|
5
|
$part->{filename} = $contentid; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
3
|
|
|
|
|
19
|
return $self->SUPER::handler($part); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Daniel Ruoso C |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 LICENSE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This library is free software . You can redistribute it and/or modify |
98
|
|
|
|
|
|
|
it under the same terms as perl itself. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |