Class HttpUtil
- java.lang.Object
-
- com.google.android.exoplayer2.upstream.HttpUtil
-
public final class HttpUtil extends Object
Utility methods for HTTP.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringbuildRangeRequestHeader(long position, long length)Builds aRange headerfor the given position and length.static longgetContentLength(String contentLengthHeader, String contentRangeHeader)Attempts to parse the length of a response body from the corresponding response headers.static longgetDocumentSize(String contentRangeHeader)Attempts to parse the document size from aContent-Range header.
-
-
-
Method Detail
-
buildRangeRequestHeader
@Nullable public static String buildRangeRequestHeader(long position, long length)
Builds aRange headerfor the given position and length.- Parameters:
position- The request position.length- The request length, orC.LENGTH_UNSETif the request is unbounded.- Returns:
- The corresponding range header, or
nullif a header is unnecessary because the whole resource is being requested.
-
getDocumentSize
public static long getDocumentSize(@Nullable String contentRangeHeader)Attempts to parse the document size from aContent-Range header.- Parameters:
contentRangeHeader- TheContent-Range header, ornullif not set.- Returns:
- The document size, or
C.LENGTH_UNSETif it could not be determined.
-
getContentLength
public static long getContentLength(@Nullable String contentLengthHeader, @Nullable String contentRangeHeader)Attempts to parse the length of a response body from the corresponding response headers.- Parameters:
contentLengthHeader- TheContent-Length header, ornullif not set.contentRangeHeader- TheContent-Range header, ornullif not set.- Returns:
- The length of the response body, or
C.LENGTH_UNSETif it could not be determined.
-
-