ktor-http / io.ktor.http.content

Package io.ktor.http.content

Types

ByteArrayContent

class ByteArrayContent : ByteArrayContent

Implementation of the OutgoingContent.ByteArrayContent for sending array of bytes

CachingOptions

data class CachingOptions

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

ChannelWriterContent

class ChannelWriterContent : WriteChannelContent

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

EntityTagVersion

data class EntityTagVersion : 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

LastModifiedVersion

data class LastModifiedVersion : Version

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

MultiPartData

interface MultiPartData

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

OutgoingContent

sealed class OutgoingContent

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

OutputStreamContent

class OutputStreamContent : WriteChannelContent

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

PartData

sealed class PartData

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

TextContent

class TextContent : ByteArrayContent

Represents a text content that could be sent

URIFileContent

class URIFileContent : ReadChannelContent

Represents a content that is served from the specified uri

Version

interface Version

Represents content version

VersionCheckResult

enum class VersionCheckResult

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

WriterContent

class WriterContent : WriteChannelContent

Represents a content that is produced by body function

Properties

CachingProperty

val CachingProperty: AttributeKey<CachingOptions>

Specifies a key for CacheControl extension property for OutgoingContent

VersionListProperty

val VersionListProperty: AttributeKey<List<Version>>

Specifies a key for VersionList extension property for OutgoingContent

caching

var OutgoingContent.caching: CachingOptions?

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

streamProvider

val FileItem.streamProvider: () -> InputStream

Provides file item's content as an InputStream

versions

var OutgoingContent.versions: List<Version>

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

Functions

EntityTagVersion

fun EntityTagVersion(spec: String): EntityTagVersion

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

forEachPart

suspend fun MultiPartData.forEachPart(partHandler: suspend (PartData) -> Unit): Unit

Parse multipart data stream and invoke partHandler for each PartData encountered

readAllParts

suspend fun MultiPartData.readAllParts(): List<PartData>

Parse multipart data stream and put all parts into a list