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
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

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
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
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 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

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