Package org.dellroad.msrp.msg
Class MsrpInputParser
- java.lang.Object
-
- org.dellroad.msrp.msg.MsrpInputParser
-
public class MsrpInputParser extends Object
Stateful MSRP message parser.Instances are configured with various size limits to avoid unbounded memory usage.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_CONTENT_LENGTHDefault maximum content length (16777216)static intDEFAULT_MAX_EXTENSION_HEADERSDefault maximum number of extension headers (32)static intDEFAULT_MAX_LINE_LENGTHDefault maximum line length in bytes (16384)static intDEFAULT_MAX_MIME_HEADERSDefault maximum number of MIME headers length (16)static intDEFAULT_MAX_PATH_URISDefault maximum number of URIs inTo-PathorFrom-Path(32)
-
Constructor Summary
Constructors Constructor Description MsrpInputParser()Constructor.MsrpInputParser(int maxLineLength, int maxBodySize, int maxPathUris, int maxMimeHeaders, int maxExtensionHeaders)Primary constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MsrpMessageinputMessageByte(byte b)Input the next byte.booleanisBetweenMessages()Determine whether this instance is sitting at a message boundary.voidreset()Reset parse state.
-
-
-
Field Detail
-
DEFAULT_MAX_LINE_LENGTH
public static final int DEFAULT_MAX_LINE_LENGTH
Default maximum line length in bytes (16384)- See Also:
- Constant Field Values
-
DEFAULT_MAX_CONTENT_LENGTH
public static final int DEFAULT_MAX_CONTENT_LENGTH
Default maximum content length (16777216)- See Also:
- Constant Field Values
-
DEFAULT_MAX_PATH_URIS
public static final int DEFAULT_MAX_PATH_URIS
Default maximum number of URIs inTo-PathorFrom-Path(32)- See Also:
- Constant Field Values
-
DEFAULT_MAX_MIME_HEADERS
public static final int DEFAULT_MAX_MIME_HEADERS
Default maximum number of MIME headers length (16)- See Also:
- Constant Field Values
-
DEFAULT_MAX_EXTENSION_HEADERS
public static final int DEFAULT_MAX_EXTENSION_HEADERS
Default maximum number of extension headers (32)- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MsrpInputParser
public MsrpInputParser()
Constructor. Uses default size limits.
-
MsrpInputParser
public MsrpInputParser(int maxLineLength, int maxBodySize, int maxPathUris, int maxMimeHeaders, int maxExtensionHeaders)Primary constructor.- Parameters:
maxLineLength- maximum allowed header line length in bytesmaxBodySize- maximum allowed body size in bytesmaxPathUris- maximum number of URI's allowed inTo-PathorFrom-PathheadermaxMimeHeaders- maximum number of allowed MIME headersmaxExtensionHeaders- maximum number of allowed extension headers- Throws:
IllegalArgumentException- ifinputis null
-
-
Method Detail
-
inputMessageByte
public MsrpMessage inputMessageByte(byte b) throws ProtocolException
Input the next byte.- Parameters:
b- input byte- Returns:
- next complete message, or null if more bytes are needed
- Throws:
ProtocolException- if a protocol violation is detected
-
reset
public void reset()
Reset parse state.
-
isBetweenMessages
public boolean isBetweenMessages()
Determine whether this instance is sitting at a message boundary.This will be true after initial construction, an invocation of
reset(), or an invocationinputMessageByte()that returned a non-null value.- Returns:
- true if positioned at a message boundary
-
-