ktor-http-cio / io.ktor.http.cio

Package io.ktor.http.cio

Types

CIOHeaders

class CIOHeaders : Headers

An adapter from CIO low-level headers map to ktor Headers interface

CIOMultipartDataBase

class CIOMultipartDataBase : MultiPartData, CoroutineScope

Represents a multipart data object that does parse and convert parts to ktor's PartData

ConnectionOptions

class ConnectionOptions

Represents a parsed Connection header

HttpHeadersMap

class HttpHeadersMap

A headers map data structure used in CIO

HttpMessage

abstract class HttpMessage

Represents a base HTTP message type for request and response

MultipartEvent

sealed class MultipartEvent

Represents a multipart content starting event. Every part need to be completely consumed or released via release

Request

class Request : HttpMessage

Represents an HTTP request

RequestResponseBuilder

expect class RequestResponseBuilder

Builds an HTTP request or response

Response

class Response : HttpMessage

Represents an HTTP response

Exceptions

ParserException

class ParserException : Exception

An HTTP parser exception

Type Aliases

DecoderJob

typealias DecoderJob = WriterJob

Decoder job type

EncoderJob

typealias EncoderJob = ReaderJob

Encoder job type

HttpRequestHandler

typealias HttpRequestHandler = suspend ServerRequestScope.(request: Request) -> Unit

HTTP request handler function

Extensions for External Classes

kotlinx.coroutines.CoroutineScope

Properties

HttpPipelineCoroutine

val HttpPipelineCoroutine: CoroutineName

HTTP pipeline coroutine name

HttpPipelineWriterCoroutine

val HttpPipelineWriterCoroutine: CoroutineName

HTTP pipeline writer coroutine name

RequestHandlerCoroutine

val RequestHandlerCoroutine: CoroutineName

HTTP request handler coroutine name

Functions

boundary

suspend fun boundary(boundaryPrefixed: ByteBuffer, input: ByteReadChannel): Boolean

Skip multipart boundary

copyMultipart

suspend fun copyMultipart(headers: HttpHeadersMap, input: ByteReadChannel, out: ByteWriteChannel): Unit

decodeChunked

suspend fun decodeChunked(input: ByteReadChannel, out: ByteWriteChannel): Unit

Decode chunked transfer encoding from the input channel and write the result in out.

suspend fun decodeChunked(input: ByteReadChannel, out: ByteWriteChannel, contentLength: Long): Unit

Chunked stream decoding loop

dumpTo

fun HttpHeadersMap.dumpTo(indent: String, out: Appendable): Unit

Dump header values to out, useful for debugging

encodeChunked

suspend fun encodeChunked(output: ByteWriteChannel, coroutineContext: <ERROR CLASS>): EncoderJob

Start chunked stream encoding coroutine

suspend fun encodeChunked(output: ByteWriteChannel, input: ByteReadChannel): Unit

Chunked stream encoding loop

expectHttpBody

fun expectHttpBody(method: HttpMethod, contentLength: Long, transferEncoding: CharSequence?, connectionOptions: ConnectionOptions?, contentType: CharSequence?): Boolean
fun expectHttpBody(request: Request): Boolean

expectHttpUpgrade

fun expectHttpUpgrade(method: HttpMethod, upgrade: CharSequence?, connectionOptions: ConnectionOptions?): Boolean
fun expectHttpUpgrade(request: Request): Boolean

expectMultipart

fun expectMultipart(headers: HttpHeadersMap): Boolean

Check if we have multipart content

lastHttpRequest

fun lastHttpRequest(http11: Boolean, connectionOptions: ConnectionOptions?): Boolean

parseBoundary

fun parseBoundary(contentType: CharSequence): ByteBuffer

Parse multipart boundary encoded in contentType header value

parseHeaders

suspend fun parseHeaders(input: ByteReadChannel): HttpHeadersMap

Parse http headers. Not applicable to request and response status lines.

parseHttpBody

suspend fun parseHttpBody(contentLength: Long, transferEncoding: CharSequence?, connectionOptions: ConnectionOptions?, input: ByteReadChannel, out: ByteWriteChannel): Unit

Parse HTTP request or response body using contentLength, transferEncoding and connectionOptions writing it to out. Usually doesn't fail but closing out channel with error.

suspend fun parseHttpBody(headers: HttpHeadersMap, input: ByteReadChannel, out: ByteWriteChannel): Unit

Parse HTTP request or response body using request/response's headers writing it to out. Usually doesn't fail but closing out channel with error.

parseMultipart

fun parseMultipart(coroutineContext: <ERROR CLASS>, input: ByteReadChannel, headers: HttpHeadersMap): ReceiveChannel<MultipartEvent>
fun parseMultipart(coroutineContext: <ERROR CLASS>, input: ByteReadChannel, contentType: CharSequence, contentLength: Long?): ReceiveChannel<MultipartEvent>
fun parseMultipart(coroutineContext: <ERROR CLASS>, boundaryPrefixed: ByteBuffer, input: ByteReadChannel, totalLength: Long?): ReceiveChannel<MultipartEvent>

parsePart

suspend fun parsePart(boundaryPrefixed: ByteBuffer, input: ByteReadChannel, output: ByteWriteChannel, limit: Long = Long.MAX_VALUE): Pair<HttpHeadersMap, Long>

Parse multipart part headers and body. Body bytes will be copied to output but up to limit bytes

parsePartBody

suspend fun parsePartBody(boundaryPrefixed: ByteBuffer, input: ByteReadChannel, output: ByteWriteChannel, headers: HttpHeadersMap, limit: Long = Long.MAX_VALUE): Long

Parse multipart part body copying them to output channel but up to limit bytes

parsePartHeaders

suspend fun parsePartHeaders(input: ByteReadChannel): HttpHeadersMap

Parse multipart part headers

parsePreamble

suspend fun parsePreamble(boundaryPrefixed: ByteBuffer, input: ByteReadChannel, output: BytePacketBuilder, limit: Long = Long.MAX_VALUE): Long

Parse a multipart preamble

parseRequest

suspend fun parseRequest(input: ByteReadChannel): Request?

Parse an HTTP request line and headers

parseResponse

suspend fun parseResponse(input: ByteReadChannel): Response?

Parse an HTTP response status line and headers