Class MultiPart.Parser

java.lang.Object
org.eclipse.jetty.http.MultiPart.Parser
Enclosing class:
MultiPart

public static class MultiPart.Parser extends Object

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:
  • Constructor Details

  • Method Details

    • getBoundary

      public String 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 a MultiPart.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

      public void parse(Content.Chunk chunk)

      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 - the Content.Chunk to parse
      See Also: