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 OutgoingContent such as Cache-Control or Expires.

Link copied to clipboard
class ChannelWriterContent(body: suspend ByteWriteChannel.() -> Unit, contentType: ContentType?, status: HttpStatusCode?, contentLength: Long?) : 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 the etag value and pass it through conditions supplied by the remote client. Depending on the conditions, it produces the return value of enum type VersionCheckResult.

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

Creates an instance of LastModifiedVersion that passes the given lastModified date through the If-Modified-Since and If-Unmodified-Since conditional headers provided by the client.

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?, contentLength: Long?) : 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, contentLength: Long?) : OutgoingContent.ReadChannelContent

Represents a content that is served from the specified uri

Link copied to clipboard
interface Version

A content version.

Link copied to clipboard
enum VersionCheckResult : Enum<VersionCheckResult>

Represent the 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?, contentLength: Long?) : 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
fun LastModifiedVersion(lastModified: Date): LastModifiedVersion

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
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 the CacheControl instance as an extension property on this content.

Link copied to clipboard
val CachingProperty: AttributeKey<CachingOptions>

Specifies a key for the 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 the VersionList extension property for OutgoingContent.

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

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