Package io.ktor.http.cio

Types

Link copied to clipboard
class CIOHeaders(headers: HttpHeadersMap) : Headers

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

Link copied to clipboard
class CIOMultipartDataBase(coroutineContext: CoroutineContext, channel: ByteReadChannel, contentType: CharSequence, contentLength: Long?, formFieldLimit: Int, inMemoryFileUploadLimit: Int) : MultiPartData, CoroutineScope

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

Link copied to clipboard
class ConnectionOptions(close: Boolean, keepAlive: Boolean, upgrade: Boolean, extraOptions: List<String>)

Represents a parsed Connection header

Link copied to clipboard
typealias DecoderJob = WriterJob

Decoder job type

Link copied to clipboard
typealias EncoderJob = ReaderJob

Encoder job type

Link copied to clipboard
class HttpHeadersMap

A headers map data structure used in CIO

Link copied to clipboard
abstract class HttpMessage : Closeable

Represents a base HTTP message type for request and response

Link copied to clipboard
typealias HttpRequestHandler = suspend ServerRequestScope.(request: Request) -> Unit

HTTP request handler function

Link copied to clipboard
sealed class MultipartEvent

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

Link copied to clipboard
class ParserException(message: String) : Exception

An HTTP parser exception

Link copied to clipboard
class Request : HttpMessage

Represents an HTTP request

Link copied to clipboard
expect class RequestResponseBuilder

Builds an HTTP request or response

actual class RequestResponseBuilder

Builds an HTTP request or response

actual class RequestResponseBuilder

Builds an HTTP request or response

Link copied to clipboard
class Response : HttpMessage

Represents an HTTP response

Functions

Link copied to clipboard
suspend fun boundary(boundaryPrefixed: ByteBuffer, input: ByteReadChannel): Boolean

Skip multipart boundary

Link copied to clipboard
suspend fun copyMultipart(headers: HttpHeadersMap, input: ByteReadChannel, out: ByteWriteChannel)
Link copied to clipboard
fun CoroutineScope.decodeChunked(input: ByteReadChannel): DecoderJob
fun CoroutineScope.decodeChunked(input: ByteReadChannel, contentLength: Long): DecoderJob

Start a chunked stream decoder coroutine

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

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

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

Chunked stream decoding loop

Link copied to clipboard
fun HttpHeadersMap.dumpTo(indent: String, out: Appendable)

Dump header values to out, useful for debugging

Link copied to clipboard
suspend fun encodeChunked(output: ByteWriteChannel, input: ByteReadChannel)

Chunked stream encoding loop

suspend fun encodeChunked(output: ByteWriteChannel, coroutineContext: CoroutineContext): EncoderJob

Start chunked stream encoding coroutine

Link copied to clipboard
fun expectHttpBody(request: Request): Boolean
fun expectHttpBody(method: HttpMethod, contentLength: Long, transferEncoding: CharSequence?, connectionOptions: ConnectionOptions?, contentType: CharSequence?): Boolean
Link copied to clipboard
fun expectHttpUpgrade(request: Request): Boolean
fun expectHttpUpgrade(method: HttpMethod, upgrade: CharSequence?, connectionOptions: ConnectionOptions?): Boolean
Link copied to clipboard
fun expectMultipart(headers: HttpHeadersMap): Boolean

Check if we have multipart content

Link copied to clipboard
fun lastHttpRequest(http11: Boolean, connectionOptions: ConnectionOptions?): Boolean
Link copied to clipboard
fun parseBoundary(contentType: CharSequence): ByteBuffer

Parse multipart boundary encoded in contentType header value

Link copied to clipboard
suspend fun parseHeaders(input: ByteReadChannel): HttpHeadersMap

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

Link copied to clipboard
suspend fun parseHttpBody(headers: HttpHeadersMap, input: ByteReadChannel, out: ByteWriteChannel)

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.

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

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.

Link copied to clipboard
fun CoroutineScope.parseMultipart(input: ByteReadChannel, headers: HttpHeadersMap): ReceiveChannel<MultipartEvent>
fun CoroutineScope.parseMultipart(input: ByteReadChannel, contentType: CharSequence, contentLength: Long?): ReceiveChannel<MultipartEvent>
fun CoroutineScope.parseMultipart(boundaryPrefixed: ByteBuffer, input: ByteReadChannel, totalLength: Long?): ReceiveChannel<MultipartEvent>

Starts a multipart parser coroutine producing multipart events

fun parseMultipart(coroutineContext: CoroutineContext, input: ByteReadChannel, headers: HttpHeadersMap): ReceiveChannel<MultipartEvent>
fun parseMultipart(coroutineContext: CoroutineContext, input: ByteReadChannel, contentType: CharSequence, contentLength: Long?): ReceiveChannel<MultipartEvent>
fun parseMultipart(coroutineContext: CoroutineContext, boundaryPrefixed: ByteBuffer, input: ByteReadChannel, totalLength: Long?): ReceiveChannel<MultipartEvent>
Link copied to clipboard
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

Link copied to clipboard
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

Link copied to clipboard
suspend fun parsePartHeaders(input: ByteReadChannel): HttpHeadersMap

Parse multipart part headers

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

Parse a multipart preamble

Link copied to clipboard
suspend fun parseRequest(input: ByteReadChannel): Request?

Parse an HTTP request line and headers

Link copied to clipboard
suspend fun parseResponse(input: ByteReadChannel): Response?

Parse an HTTP response status line and headers

Link copied to clipboard
fun CoroutineScope.startConnectionPipeline(input: ByteReadChannel, output: ByteWriteChannel, timeout: WeakTimeoutQueue, handler: suspend CoroutineScope.(request: Request, input: ByteReadChannel, output: ByteWriteChannel, upgraded: CompletableDeferred<Boolean>?) -> Unit): Job

Start connection HTTP pipeline invoking handler for every request. Note that handler could be invoked multiple times concurrently due to HTTP pipeline nature

Properties

Link copied to clipboard
val HttpPipelineCoroutine: CoroutineName

HTTP pipeline coroutine name

Link copied to clipboard
val HttpPipelineWriterCoroutine: CoroutineName

HTTP pipeline writer coroutine name

Link copied to clipboard
val RequestHandlerCoroutine: CoroutineName

HTTP request handler coroutine name