类 HttpRange
- java.lang.Object
- org.springframework.http.HttpRange
public abstract class HttpRange extends Object
Represents an HTTP (byte) range for use with the HTTP"Range"
header.- 从以下版本开始:
- 4.2
- 作者:
- Arjen Poutsma, Juergen Hoeller
- 另请参阅:
- HTTP/1.1: Range Requests,
HttpHeaders.setRange(List)
,HttpHeaders.getRange()
构造器概要
构造器 构造器 说明 HttpRange()
方法概要
所有方法 静态方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 static HttpRange
createByteRange(long firstBytePos)
Create anHttpRange
from the given position to the end.static HttpRange
createByteRange(long firstBytePos, long lastBytePos)
Create aHttpRange
from the given fist to last position.static HttpRange
createSuffixRange(long suffixLength)
Create anHttpRange
that ranges over the last given number of bytes.abstract long
getRangeEnd(long length)
Return the end of the range (inclusive) given the total length of a representation.abstract long
getRangeStart(long length)
Return the start of the range given the total length of a representation.static List<HttpRange>
parseRanges(String ranges)
Parse the given, comma-separated string into a list ofHttpRange
objects.ResourceRegion
toResourceRegion(Resource resource)
Turn aResource
into aResourceRegion
using the range information contained in the currentHttpRange
.static List<ResourceRegion>
toResourceRegions(List<HttpRange> ranges, Resource resource)
Convert eachHttpRange
into aResourceRegion
, selecting the appropriate segment of the givenResource
using HTTP Range information.static String
toString(Collection<HttpRange> ranges)
Return a string representation of the given list ofHttpRange
objects.
构造器详细资料
HttpRange
public HttpRange()
方法详细资料
toResourceRegion
public ResourceRegion toResourceRegion(Resource resource)
Turn aResource
into aResourceRegion
using the range information contained in the currentHttpRange
.- 参数:
resource
- theResource
to select the region from- 返回:
- the selected region of the given
Resource
- 从以下版本开始:
- 4.3
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
public static HttpRange createByteRange(long firstBytePos)
Create anHttpRange
from the given position to the end.- 参数:
firstBytePos
- the first byte position- 返回:
- a byte range that ranges from
firstPos
till the end - 另请参阅:
- Byte Ranges
createByteRange
public static HttpRange createByteRange(long firstBytePos, long lastBytePos)
Create aHttpRange
from the given fist to last position.- 参数:
firstBytePos
- the first byte positionlastBytePos
- the last byte position- 返回:
- a byte range that ranges from
firstPos
tilllastPos
- 另请参阅:
- Byte Ranges
createSuffixRange
public static HttpRange createSuffixRange(long suffixLength)
Create anHttpRange
that ranges over the last given number of bytes.- 参数:
suffixLength
- the number of bytes for the range- 返回:
- a byte range that ranges over the last
suffixLength
number of bytes - 另请参阅:
- Byte Ranges
parseRanges
public static List<HttpRange> parseRanges(String ranges)
Parse the given, comma-separated string into a list ofHttpRange
objects.This method can be used to parse an
Range
header.- 参数:
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
toResourceRegions
public static List<ResourceRegion> toResourceRegions(List<HttpRange> ranges, Resource resource)
Convert eachHttpRange
into aResourceRegion
, selecting the appropriate segment of the givenResource
using 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- 从以下版本开始:
- 4.3
toString
public static String toString(Collection<HttpRange> ranges)
Return a string representation of the given list ofHttpRange
objects.This method can be used to for an
Range
header.- 参数:
ranges
- the ranges to create a string of- 返回:
- the string representation