1HTTP::MultiPartParser(3U)ser Contributed Perl DocumentatiHoTnTP::MultiPartParser(3)
2
3
4
6 HTTP::MultiPartParser - HTTP MultiPart Parser
7
9 $parser = HTTP::MultiPartParser->new(
10 boundary => $boundary,
11 on_header => $on_header,
12 on_body => $on_body,
13 );
14
15 while ($octets = read_octets_from_body()) {
16 $parser->parse($octets);
17 }
18
19 $parser->finish;
20
22 This class provides a low-level API for processing MultiPart MIME data
23 streams conforming to MultiPart types as defined in RFC 2616
24 <http://tools.ietf.org/html/rfc2616#section-3.7.2>.
25
27 new
28 $parser = HTTP::MultiPartParser->new( %attributes );
29
30 This constructor returns a instance of "HTTP::MultiPartParser". Valid
31 attributes inculde:
32
33 • "boundary" (Mandatory)
34
35 boundary => $value
36
37 The unquoted and unescaped boundary parameter value from the
38 Content-Type header field. The boundary parameter value consist of
39 a restricted set of characters as defined in RFC 2046
40 <http://tools.ietf.org/html/rfc2046#section-5.1.1>.
41
42 DIGIT / ALPHA / "'" / "(" / ")" /
43 "+" / "_" / "," / "-" / "." /
44 "/" / ":" / "=" / "?"
45
46 • "on_header" (Mandatory)
47
48 on_header => $callback->($header)
49
50 This callback will be invoked when the header of a part has
51 successfully been received. The callback will only be invoked once
52 for each part.
53
54 • "on_header_as"
55
56 on_header_as => 'unparsed' | 'lines'
57
58 Defines the $header value for the "on_header" callback.
59
60 • "unparsed"
61
62 Callback invoked with an octet string containing the unparsed
63 header.
64
65 • "lines"
66
67 Callback invoked with an ARRAY reference, where each element of
68 the array is a header line. Folding whitespace is removed from
69 all lines and header continuation lines are unwrapped.
70
71 • "on_body" (Mandatory)
72
73 on_body => $callback->($chunk, $final)
74
75 This callback will be invoked when there is any data available for
76 the body of a part. The callback may be invoked multiple times for
77 each part.
78
79 • "on_error"
80
81 on_error => $callback->($message)
82
83 This callback will be invoked anytime an error occurs in the
84 parser. After receiving an error the parser is no longer useful in
85 its current state.
86
87 • "max_preamble_size"
88
89 max_preamble_size => 32768
90
91 • "max_header_size"
92
93 max_header_size => 32768
94
95 parse
96 $parser->parse($octets);
97
98 Parses the given octets.
99
100 finish
101 $parser->finish;
102
103 Finish the parsing.
104
105 reset
106 $parser->reset;
107
108 Resets the state of the parser.
109
110 is_aborted
111 $boolean = $parser->is_aborted;
112
113 Returns true if an error has occurred in the parser.
114
116 (F) Usage: %s
117 Method called with wrong number of arguments.
118
120 RFC 2616 section 3.7.2 Multipart Types
121 <http://tools.ietf.org/html/rfc2616#section-3.7.2>
122 RFC 2046 section 5.1.1 Common Syntax
123 <http://tools.ietf.org/html/rfc2046#section-5.1.1>
124 RFC 2388 multipart/form-data <http://tools.ietf.org/html/rfc2388>
125
127 Bugs / Feature Requests
128 Please report any bugs or feature requests through the issue tracker at
129 <https://github.com/chansen/p5-http-multipartparser/issues>. You will
130 be notified automatically of any progress on your issue.
131
132 SOURCE CODE
133 This is open source software. The code repository is available for
134 public review and contribution under the terms of the license.
135
136 <httsp://github.com/chansen/p5-http-multipartparser>
137
138 git clone https://github.com/chansen/p5-http-multipartparser
139
141 Christian Hansen "chansen@cpan.org"
142
144 Copyright 2012-2017 by Christian Hansen.
145
146 This is free software; you can redistribute it and/or modify it under
147 the same terms as the Perl 5 programming language system itself.
148
149
150
151perl v5.34.0 2021-07-22 HTTP::MultiPartParser(3)