Package io.ktor.http.content

Types

Link copied to clipboard
class ByteArrayContent(bytes: ByteArray, contentType: ContentType?, status: HttpStatusCode?) : OutgoingContent.ByteArrayContent

Implementation of the OutgoingContent.ByteArrayContent for sending array of bytes

Link copied to clipboard
data class CachingOptions(cacheControl: CacheControl?, expires: GMTDate?)

Specifies caching properties for an OutgoingContent such as Cache-Control or Expires

Link copied to clipboard
class ChannelWriterContent(body: suspend ByteWriteChannel.() -> Unit, contentType: ContentType?, status: HttpStatusCode?) : OutgoingContent.WriteChannelContent

OutgoingContent to respond with ByteWriteChannel. The stream would be automatically closed after body finish.

Link copied to clipboard
data class EntityTagVersion(etag: String, weak: Boolean) : Version

This version checks etag value and pass it through conditions supplied by the remote client. Depending on conditions it produces return value of enum type VersionCheckResult

Link copied to clipboard
data class LastModifiedVersion(lastModified: GMTDate) : Version

This version passes the given lastModified date through the client provided http conditional headers If-Modified-Since and If-Unmodified-Since.

Link copied to clipboard
interface MultiPartData

Represents a multipart data stream that could be received from a call

Link copied to clipboard
sealed class OutgoingContent

Information about the content to be sent to the peer, recognized by a client or server engine

Link copied to clipboard
class OutputStreamContent(body: suspend OutputStream.() -> Unit, contentType: ContentType, status: HttpStatusCode?) : OutgoingContent.WriteChannelContent

OutgoingContent to respond with OutputStream. The stream would be automatically closed after body finish.

Link copied to clipboard
sealed class PartData

Represents a multipart/form-data entry. Could be a FormItem or FileItem

Link copied to clipboard
class TextContent(text: String, contentType: ContentType, status: HttpStatusCode?) : OutgoingContent.ByteArrayContent

Represents a text content that could be sent

Link copied to clipboard
class URIFileContent(uri: URI, contentType: ContentType) : OutgoingContent.ReadChannelContent

Represents a content that is served from the specified uri

Link copied to clipboard
interface Version

Represents content version

Link copied to clipboard
enum VersionCheckResult : Enum<VersionCheckResult>

Represent result of the version comparison between content being sent and HTTP request.

Link copied to clipboard
class WriterContent(body: suspend Writer.() -> Unit, contentType: ContentType, status: HttpStatusCode?) : OutgoingContent.WriteChannelContent

Represents a content that is produced by body function

Functions

Link copied to clipboard
fun EntityTagVersion(spec: String): EntityTagVersion

Creates an instance of EntityTagVersion parsing the spec via EntityTagVersion.parseSingle.

Link copied to clipboard
suspend fun MultiPartData.forEachPart(partHandler: suspend (PartData) -> Unit)

Parse multipart data stream and invoke partHandler for each PartData encountered

Link copied to clipboard
suspend fun MultiPartData.readAllParts(): List<PartData>

Parse multipart data stream and put all parts into a list

Properties

Link copied to clipboard
var OutgoingContent.caching: CachingOptions?

Gets or sets CacheControl instance as an extension property on this content

Link copied to clipboard
val CachingProperty: AttributeKey<CachingOptions>

Specifies a key for CacheControl extension property for OutgoingContent

Link copied to clipboard
val PartData.FileItem.streamProvider: () -> InputStream

Provides file item's content as an InputStream

Link copied to clipboard
val VersionListProperty: AttributeKey<List<Version>>

Specifies a key for VersionList extension property for OutgoingContent

Link copied to clipboard
var OutgoingContent.versions: List<Version>

Gets or sets list of Version instances as an extension property on this content