Class ContentRange
java.lang.Object
org.apache.tomcat.util.http.parser.ContentRange
Represents a parsed Content-Range HTTP header value as defined by RFC 9110.
-
Constructor Summary
ConstructorsConstructorDescriptionContentRange(String units, long start, long end, long length) Creates a new ContentRange with the specified values. -
Method Summary
Modifier and TypeMethodDescriptionlonggetEnd()Returns the end position of the content range.longReturns the total length of the resource.longgetStart()Returns the start position of the content range.getUnits()Returns the range units (e.g., "bytes") in lower case.booleanisValid()Validates this content range according to RFC 9110 section 14.4.static ContentRangeparse(StringReader input) Parses a Content-Range header from an HTTP header.
-
Constructor Details
-
ContentRange
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 Details
-
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
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:
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
-