@UnstableApi
class HttpUtil


Utility methods for HTTP.

Summary

Public functions

java-static String?
buildRangeRequestHeader(position: Long, length: Long)

Builds a Range header for the given position and length.

java-static Long
getContentLength(contentLengthHeader: String?, contentRangeHeader: String?)

Attempts to parse the length of a response body from the corresponding response headers.

java-static Long
getDocumentSize(contentRangeHeader: String?)

Attempts to parse the document size from a Content-Range header.

Public functions

buildRangeRequestHeader

java-static fun buildRangeRequestHeader(position: Long, length: Long): String?

Builds a Range header for the given position and length.

Parameters
position: Long

The request position.

length: Long

The request length, or LENGTH_UNSET if the request is unbounded.

Returns
String?

The corresponding range header, or null if a header is unnecessary because the whole resource is being requested.

getContentLength

java-static fun getContentLength(contentLengthHeader: String?, contentRangeHeader: String?): Long

Attempts to parse the length of a response body from the corresponding response headers.

Parameters
contentLengthHeader: String?

The Content-Length header, or null if not set.

contentRangeHeader: String?

The Content-Range header, or null if not set.

Returns
Long

The length of the response body, or LENGTH_UNSET if it could not be determined.

getDocumentSize

java-static fun getDocumentSize(contentRangeHeader: String?): Long

Attempts to parse the document size from a Content-Range header.

Parameters
contentRangeHeader: String?

The Content-Range header, or null if not set.

Returns
Long

The document size, or LENGTH_UNSET if it could not be determined.