HttpRange Class

  • java.lang.Object
    • com.azure.core.http.HttpRange

public final class HttpRange

Represents a range of bytes within an HTTP resource.

This class encapsulates a range of bytes that can be requested from an HTTP resource. The range starts at the getOffset() inclusively and ends at getOffset() + getLength() exclusively, or offset + length - 1.

If getLength() is unspecified or null, the range extends to the end of the HTTP resource.

This class is useful when you want to request a specific range of bytes from an HTTP resource, such as a part of a file. For example, you can use it to download a part of a file, to resume a download, or to stream a video from a specific point.

Constructor Summary

Constructor Description
HttpRange(long offset)

Creates an instance of HttpRange.

HttpRange(long offset, Long length)

Creates an instance of HttpRange.

Method Summary

Modifier and Type Method and Description
boolean equals(Object obj)
Long getLength()

Gets the length of the range.

long getOffset()

Gets the offset of the range.

int hashCode()
String toString()

Gets the string representation of the range.

Methods inherited from java.lang.Object

Constructor Details

HttpRange

public HttpRange(long offset)

Creates an instance of HttpRange.

This creates a range which has an unbounded length starting at the specified offset.

Parameters:

offset - The offset to begin the range.

HttpRange

public HttpRange(long offset, Long length)

Creates an instance of HttpRange.

Parameters:

offset - The offset to begin the range.
length - The length of the range.

Method Details

equals

public boolean equals(Object obj)

Overrides:

HttpRange.equals(Object obj)

Parameters:

obj

getLength

public Long getLength()

Gets the length of the range.

If the length is null the range continues to the end of the HTTP resource.

Returns:

Length of the range or null if range continues to the end of the HTTP resource.

getOffset

public long getOffset()

Gets the offset of the range.

Returns:

Offset of the range.

hashCode

public int hashCode()

Overrides:

HttpRange.hashCode()

toString

public String toString()

Gets the string representation of the range.

If length is null the returned string will be "bytes=-", if length is not null the returned string will be "bytes=-".

Overrides:

HttpRange.toString()

Returns:

The string representation of the range.

Applies to