spring-framework / org.springframework.http / HttpRange

HttpRange

abstract class HttpRange

Represents an HTTP (byte) range for use with the HTTP "Range" header.

Author
Arjen Poutsma

Author
Juergen Hoeller

Since
4.2

See Also
<a href="http://tools.ietf.org/html/rfc7233">HTTP/1.1: Range Requests</a>HttpHeaders#setRange(List)HttpHeaders#getRange()

Constructors

<init>

HttpRange()

Represents an HTTP (byte) range for use with the HTTP "Range" header.

Functions

createByteRange

open static fun createByteRange(firstBytePos: Long): HttpRange

Create an HttpRange from the given position to the end.

open static fun createByteRange(firstBytePos: Long, lastBytePos: Long): HttpRange

Create a HttpRange from the given fist to last position.

createSuffixRange

open static fun createSuffixRange(suffixLength: Long): HttpRange

Create an HttpRange that ranges over the last given number of bytes.

getRangeEnd

abstract fun getRangeEnd(length: Long): Long

Return the end of the range (inclusive) given the total length of a representation.

getRangeStart

abstract fun getRangeStart(length: Long): Long

Return the start of the range given the total length of a representation.

parseRanges

open static fun parseRanges(ranges: String): MutableList<HttpRange>

Parse the given, comma-separated string into a list of HttpRange objects.

This method can be used to parse an Range header.

toResourceRegion

open fun toResourceRegion(resource: Resource): ResourceRegion

Turn a Resource into a ResourceRegion using the range information contained in the current HttpRange.

toResourceRegions

open static fun toResourceRegions(ranges: MutableList<HttpRange>, resource: Resource): MutableList<ResourceRegion>

Convert each HttpRange into a ResourceRegion, selecting the appropriate segment of the given Resource using HTTP Range information.

toString

open static fun toString(ranges: MutableCollection<HttpRange>): String

Return a string representation of the given list of HttpRange objects.

This method can be used to for an Range header.