Skip to content

//okhttp/okhttp3/MediaType

MediaType

[common]\ expect class MediaType

An RFC 2045 Media Type, appropriate to describe the content type of an HTTP request or response body.

[jvm, nonJvm]\ actual class MediaType

Types

Name Summary
Companion [common, jvm, nonJvm]
[common]
expect object Companion
[jvm, nonJvm]
actual object Companion

Functions

Name Summary
charset [jvm]
@JvmOverloads
fun charset(defaultValue: Charset? = null): Charset?
Returns the charset of this media type, or defaultValue if either this media type doesn’t specify a charset, or if its charset is unsupported by the current runtime.
equals [jvm, nonJvm]
[jvm]
open operator override fun equals(other: Any?): Boolean
[nonJvm]
open operator override fun equals(other: Any?): Boolean
hashCode [jvm, nonJvm]
[jvm]
open override fun hashCode(): Int
[nonJvm]
open override fun hashCode(): Int
parameter [common]
expect fun parameter(name: String): String?
Returns the parameter name of this media type, or null if this media type does not define such a parameter.
[jvm, nonJvm]
[jvm, nonJvm]
actual fun parameter(name: String): String?
toString [common]
expect open override fun toString(): String
Returns the encoded media type, like "text/plain; charset=utf-8", appropriate for use in a Content-Type header.
[jvm, nonJvm]
[jvm, nonJvm]
actual open override fun toString(): String

Properties

Name Summary
subtype [common]
expect val subtype: String
Returns a specific media subtype, such as "plain" or "png", "mpeg", "mp4" or "xml".
[jvm]
@get:JvmName(name = "subtype")
actual val subtype: String
[nonJvm]
actual val subtype: String
type [common]
expect val type: String
Returns the high-level media type, such as "text", "image", "audio", "video", or "application".
[jvm]
@get:JvmName(name = "type")
actual val type: String
[nonJvm]
actual val type: String