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