URLUtilCompat


public final class URLUtilCompat


Compatibility versions of methods in android.webkit.URLUtil.

See also
URLUtil

Summary

Public methods

static @Nullable String

Extract filename from a Content-Disposition header value.

static @NonNull String
guessFileName(
    @NonNull String url,
    @Nullable String contentDisposition,
    @Nullable String mimeType
)

Guesses canonical filename that a download would have, using the URL and contentDisposition.

Public methods

getFilenameFromContentDisposition

Added in 1.11.0
public static @Nullable String getFilenameFromContentDisposition(@NonNull String contentDisposition)

Extract filename from a Content-Disposition header value.

This method implements the parsing defined in RFC 6266, supporting both the filename and filename* disposition parameters. If the passed header value has the "inline" disposition type, this method will return null to indicate that a download was not intended.

If both filename* and filename is present, the former will be returned, as per the RFC. Invalid encoded values will be ignored.

Parameters
@NonNull String contentDisposition

Value of Content-Disposition header.

<table class="res