Class MultiPart.Parser
- Enclosing class:
- MultiPart
A multipart/form-data
parser that follows
RFC 7578.
RFC 7578 mandates that end-of-lines are CRLF, but this parser is more lenient and it is able to parse multipart content that only uses LF as end-of-line.
The parser emits events specified by MultiPart.Parser.Listener
, that can be
implemented to support specific logic (for example, the max content
length of a part, etc.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A listener for events emitted by aMultiPart.Parser
. -
Constructor Summary
ConstructorDescriptionParser
(String boundary, MultiPart.Parser.Listener listener) Parser
(String boundary, MultiPartCompliance compliance, MultiPart.Parser.Listener listener) -
Method Summary
Modifier and TypeMethodDescriptionlong
int
void
parse
(Content.Chunk chunk) Parses the multipart/form-data bytes contained in the givenContent.Chunk
.void
reset()
Resets this parser to make it ready to parse again a multipart/form-data content.void
setMaxParts
(long maxParts) void
setPartHeadersMaxLength
(int partHeadersMaxLength)
-
Constructor Details
-
Parser
-
Parser
-
-
Method Details
-
getBoundary
-
getPartHeadersMaxLength
public int getPartHeadersMaxLength()- Returns:
- the max length of a
MultiPart.Part
headers, in bytes, or -1 for unlimited length
-
setPartHeadersMaxLength
public void setPartHeadersMaxLength(int partHeadersMaxLength) - Parameters:
partHeadersMaxLength
- the max length of aMultiPart.Part
headers, in bytes, or -1 for unlimited length
-
getMaxParts
public long getMaxParts()- Returns:
- the maximum number of parts that can be parsed from the multipart content (0 for no parts allowed, -1 for unlimited parts).
-
setMaxParts
public void setMaxParts(long maxParts) - Parameters:
maxParts
- the maximum number of parts that can be parsed from the multipart content (0 for no parts allowed, -1 for unlimited parts).
-
reset
public void reset()Resets this parser to make it ready to parse again a multipart/form-data content.
-
parse
Parses the multipart/form-data bytes contained in the given
Content.Chunk
.Parsing the bytes will emit events to a
MultiPart.Parser.Listener
.The multipart/form-data content may be split into multiple chunks; each chunk should be passed to this method when it is available, with the last chunk signaling that the whole multipart/form-data content has been given to this parser, which will eventually emit the
complete
event.In case of parsing errors, the
failure
event will be emitted.- Parameters:
chunk
- theContent.Chunk
to parse- See Also:
-