Class ContentRange
- java.lang.Object
-
- org.apache.tomcat.util.http.parser.ContentRange
-
public class ContentRange extends java.lang.ObjectRepresents a parsed Content-Range HTTP header value as defined by RFC 9110.
-
-
Constructor Summary
Constructors Constructor Description ContentRange(java.lang.String units, long start, long end, long length)Creates a new ContentRange with the specified values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetEnd()Returns the end position of the content range.longgetLength()Returns the total length of the resource.longgetStart()Returns the start position of the content range.java.lang.StringgetUnits()Returns the range units (e.g., "bytes") in lower case.booleanisValid()Validates this content range according to RFC 9110 section 14.4.static ContentRangeparse(java.io.StringReader input)Parses a Content-Range header from an HTTP header.
-
-
-
Constructor Detail
-
ContentRange
public ContentRange(java.lang.String units, long start, long end, long length)Creates a new ContentRange with the specified values.- Parameters:
units- the range units (e.g., "bytes"), lowercasedstart- the start position of the rangeend- the end position of the rangelength- the total length of the resource
-
-
Method Detail
-
getUnits
public java.lang.String getUnits()
Returns the range units (e.g., "bytes") in lower case.- Returns:
- the range units, or
nullif not set
-
getStart
public long getStart()
Returns the start position of the content range.- Returns:
- the start position
-
getEnd
public long getEnd()
Returns the end position of the content range.- Returns:
- the end position
-
getLength
public long getLength()
Returns the total length of the resource.- Returns:
- the total resource length
-
parse
public static ContentRange parse(java.io.StringReader input) throws java.io.IOException
Parses a Content-Range header from an HTTP header.- Parameters:
input- a reader over the header text- Returns:
- the range parsed from the input, or null if not valid
- Throws:
java.io.IOException- if there was a problem reading the input
-
isValid
public boolean isValid()
Validates this content range according to RFC 9110 section 14.4.- Returns:
trueif start >= 0, end >= start, and length > end
-
-