ContentType

interface ContentType : ComposableProperties<ERROR CLASS: Symbol not found for io.ktor.http.ContentType>

表示 HTTP 'Content-Type' 头部的值,定义了媒体类型。

一个内容类型由主类型(例如 "text")和子类型(例如 "html")组成,还可以包含额外的参数(例如 "charset=UTF-8")。

此接口是对 Ktor io.ktor.http.ContentType 的抽象封装。

Author

M8Test, [email protected], https://m8test.com

Functions

Link copied to clipboard
abstract fun getCharset(): HttpCharset?

获取此内容类型的 "charset" 参数值。

Link copied to clipboard
abstract fun getContentSubtype(): String

获取内容的子类型部分。

Link copied to clipboard
abstract fun getContentType(): String

获取内容的主类型部分。

Link copied to clipboard
abstract fun getParameter(name: String): String?

获取指定名称的参数值。

Link copied to clipboard
abstract fun match(other: (ContentTypes) -> ContentType): Boolean

检查此内容类型是否匹配另一个作为模式的 ContentType。 支持通配符 "*"。

Link copied to clipboard
abstract fun withCharset(charsetBuilder: HttpCharset.() -> Unit): ContentType

创建一个此内容类型的新副本,并添加 "charset" 参数。

Link copied to clipboard

创建一个此内容类型的新副本,但不包含任何参数。

Link copied to clipboard
abstract fun withParameter(name: String, value: String): ContentType

创建一个此内容类型的新副本,并添加一个参数。