okhttp / okhttp3 / MediaType

MediaType

class MediaType

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

Properties

Name Summary
subtype Returns a specific media subtype, such as “plain” or “png”, “mpeg”, “mp4” or “xml”.val subtype:String
type Returns the high-level media type, such as “text”, “image”, “audio”, “video”, or “application”.val type:String

Functions

Name Summary
charset Returns the charset of this media type, or defaultValue if either this media type doesn’t specify a charset, of it its charset is unsupported by the current runtime.fun charset(defaultValue:Charset? = null):Charset?
equals fun equals(other:Any?):Boolean
hashCode fun hashCode():Int
toString Returns the encoded media type, like “text/plain; charset=utf-8”, appropriate for use in a Content-Type header.fun toString():String

Companion Object Functions

Name Summary
toMediaType Returns a media type for this string.funString.toMediaType():MediaType
toMediaTypeOrNull Returns a media type for this, or null if this is not a well-formed media type.funString.toMediaTypeOrNull():MediaType?