MediaType

class MediaType

Library-owned MIME media type, e.g. application/json; charset=utf-8.

Standalone and free of any HTTP-client types (OkHttp adapters live in :lustro). Parse strings with parse; the type and subtype and any charset parameter are lower-cased, while toString preserves the original full string verbatim.

Types

Link copied to clipboard
object Companion

Parser and well-known media-type constants.

Properties

Link copied to clipboard

The lower-cased value of the charset parameter, or null if absent.

Link copied to clipboard

The subtype, lower-cased, e.g. json in application/json.

Link copied to clipboard

The primary type, lower-cased, e.g. application in application/json.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Equality by the canonical form (lower-cased type/subtype with parameters).

Link copied to clipboard
open override fun hashCode(): Int

Hash code consistent with equals.

Link copied to clipboard
fun parameter(name: String): String?

Returns the value of the ; <name>=<value> parameter (looked up case-insensitively by name), or null if the parameter is absent.

Link copied to clipboard
open override fun toString(): String

Returns the original full media-type string this was parsed from.