类 HttpRange
java.lang.Object
cn.taketoday.http.HttpRange
Represents an HTTP (byte) range for use with the HTTP
"Range" header.- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma, Juergen Hoeller, TODAY 2021/11/6 23:43
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型类说明private static classRepresents an HTTP/1.1 byte range, with a first and optional last position.private static classRepresents an HTTP/1.1 suffix byte range, with a number of suffix bytes. -
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static HttpRangecreateByteRange(long firstBytePos) Create anHttpRangefrom the given position to the end.static HttpRangecreateByteRange(long firstBytePos, long lastBytePos) Create aHttpRangefrom the given fist to last position.static HttpRangecreateSuffixRange(long suffixLength) Create anHttpRangethat ranges over the last given number of bytes.private static longgetLengthFor(cn.taketoday.core.io.Resource resource) abstract longgetRangeEnd(long length) Return the end of the range (inclusive) given the total length of a representation.abstract longgetRangeStart(long length) Return the start of the range given the total length of a representation.private static HttpRangeparseRange(String range) parseRanges(String ranges) Parse the given, comma-separated string into a list ofHttpRangeobjects.cn.taketoday.core.io.ResourceRegiontoResourceRegion(cn.taketoday.core.io.Resource resource) Turn aResourceinto aResourceRegionusing the range information contained in the currentHttpRange.static List<cn.taketoday.core.io.ResourceRegion>toResourceRegions(List<HttpRange> ranges, cn.taketoday.core.io.Resource resource) Convert eachHttpRangeinto aResourceRegion, selecting the appropriate segment of the givenResourceusing HTTP Range information.static StringtoString(Collection<HttpRange> ranges) Return a string representation of the given list ofHttpRangeobjects.
-
字段详细资料
-
构造器详细资料
-
HttpRange
public HttpRange()
-
-
方法详细资料
-
toResourceRegion
public cn.taketoday.core.io.ResourceRegion toResourceRegion(cn.taketoday.core.io.Resource resource) Turn aResourceinto aResourceRegionusing the range information contained in the currentHttpRange.- 参数:
resource- theResourceto select the region from- 返回:
- the selected region of the given
Resource
-
getRangeStart
public abstract long getRangeStart(long length) Return the start of the range given the total length of a representation.- 参数:
length- the length of the representation- 返回:
- the start of this range for the representation
-
getRangeEnd
public abstract long getRangeEnd(long length) Return the end of the range (inclusive) given the total length of a representation.- 参数:
length- the length of the representation- 返回:
- the end of the range for the representation
-
createByteRange
Create anHttpRangefrom the given position to the end.- 参数:
firstBytePos- the first byte position- 返回:
- a byte range that ranges from
firstPostill the end - 另请参阅:
-
createByteRange
Create aHttpRangefrom the given fist to last position.- 参数:
firstBytePos- the first byte positionlastBytePos- the last byte position- 返回:
- a byte range that ranges from
firstPostilllastPos - 另请参阅:
-
createSuffixRange
Create anHttpRangethat ranges over the last given number of bytes.- 参数:
suffixLength- the number of bytes for the range- 返回:
- a byte range that ranges over the last
suffixLengthnumber of bytes - 另请参阅:
-
parseRanges
Parse the given, comma-separated string into a list ofHttpRangeobjects.This method can be used to parse an
Rangeheader.- 参数:
ranges- the string to parse- 返回:
- the list of ranges
- 抛出:
IllegalArgumentException- if the string cannot be parsed or if the number of ranges is greater than 100
-
parseRange
-
toResourceRegions
public static List<cn.taketoday.core.io.ResourceRegion> toResourceRegions(List<HttpRange> ranges, cn.taketoday.core.io.Resource resource) Convert eachHttpRangeinto aResourceRegion, selecting the appropriate segment of the givenResourceusing HTTP Range information.- 参数:
ranges- the list of rangesresource- the resource to select the regions from- 返回:
- the list of regions for the given resource
- 抛出:
IllegalArgumentException- if the sum of all ranges exceeds the resource length
-
getLengthFor
private static long getLengthFor(cn.taketoday.core.io.Resource resource) -
toString
Return a string representation of the given list ofHttpRangeobjects.This method can be used to for an
Rangeheader.- 参数:
ranges- the ranges to create a string of- 返回:
- the string representation
-