HttpUtil
@UnstableApi
public final class HttpUtil
Utility methods for HTTP.
Summary
Public methods |
|
|---|---|
static @Nullable String |
buildRangeRequestHeader(long position, long length)Builds a |
static long |
getContentLength(Attempts to parse the length of a response body from the corresponding response headers. |
static String |
getCookieHeader(Returns the stored cookie header for the given response URL and headers. |
static long |
getDocumentSize(@Nullable String contentRangeHeader)Attempts to parse the document size from a |
static void |
storeCookiesFromHeaders(Stores the cookie headers from the response in the provided |
Public methods
buildRangeRequestHeader
public static @Nullable String buildRangeRequestHeader(long position, long length)
Builds a Range header for the given position and length.
| Parameters | |
|---|---|
long position |
The request position. |
long length |
The request length, or |
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 | |
|---|---|
@Nullable String contentLengthHeader |
The |
@Nullable String contentRangeHeader |
The |
| Returns | |
|---|---|
long |
The length of the response body, or |
getCookieHeader
public static String getCookieHeader(
String url,
Map<String, List<String>> headers,
@Nullable CookieHandler cookieHandler
)
Returns the stored cookie header for the given response URL and headers.
| Parameters | |
|---|---|
String url |
The URL of the response. |
Map<String, List<String>> headers |
The headers of the response. |
@Nullable CookieHandler cookieHandler |
The |
getDocumentSize
public static long getDocumentSize(@Nullable String contentRangeHeader)
Attempts to parse the document size from a Content-Range header.
| Parameters | |
|---|---|
@Nullable String contentRangeHeader |
The |
| Returns | |
|---|---|
long |
The document size, or |
storeCookiesFromHeaders
public static void storeCookiesFromHeaders(
String url,
Map<String, List<String>> headers,
@Nullable CookieHandler cookieHandler
)
Stores the cookie headers from the response in the provided CookieHandler.
| Parameters | |
|---|---|
String url |
The URL of the response. |
Map<String, List<String>> headers |
The headers of the response. |
@Nullable CookieHandler cookieHandler |
The |