NettyApplicationRequest

abstract class NettyApplicationRequest : 
    BaseApplicationRequest,
    CoroutineScope

Constructors

<init>

NettyApplicationRequest(
    call: ApplicationCall,
    coroutineContext: <ERROR CLASS>,
    context: ChannelHandlerContext,
    requestBodyChannel: ByteReadChannel,
    uri: String,
    keepAlive: Boolean)

Properties

context

val context: ChannelHandlerContext

cookies

open val cookies: RequestCookies

Cookies for this request

coroutineContext

open val coroutineContext: <ERROR CLASS>

queryParameters

val queryParameters: Parameters

Parameters provided in an URL

uri

val uri: String

Inherited Properties

call

open val call: ApplicationCall

ApplicationCall instance this ApplicationRequest is attached to

pipeline

open val pipeline: ApplicationReceivePipeline

Pipeline for receiving content

Functions

close

fun close(): Unit

newDecoder

abstract fun newDecoder(): HttpPostMultipartRequestDecoder

receiveChannel

open fun receiveChannel(): ByteReadChannel

Request’s body channel (for content only)

Extension Properties

httpMethod

Returns request HTTP method possibly overridden via header X-Http-Method-Override

httpVersion

val ApplicationRequest.httpVersion: String

Request’s HTTP version

javaSecurityPrincipal

val ApplicationRequest.javaSecurityPrincipal: Principal?

Returns Java’s JAAS Principal

origin

Represents request and connection parameters possibly overridden via https headers. By default it fallbacks to ApplicationRequest.local

uri

Request’s URI (including query string)

Extension Functions

accept

fun ApplicationRequest.accept(): String?

Request’s Accept header value

acceptCharset

fun ApplicationRequest.acceptCharset(): String?

Request’s Accept-Charset header value

acceptCharsetItems

fun ApplicationRequest.acceptCharsetItems(): List<HeaderValue>

Parsed and sorted request’s Accept-Charset header value

acceptEncoding

fun ApplicationRequest.acceptEncoding(): String?

Request’s Accept-Encoding header value

acceptEncodingItems

fun ApplicationRequest.acceptEncodingItems(): List<HeaderValue>

Parsed and sorted request’s Accept-Encoding header value

acceptItems

fun ApplicationRequest.acceptItems(): List<HeaderValue>

Parsed request’s Accept header and sorted according to quality

acceptLanguage

fun ApplicationRequest.acceptLanguage(): String?

Request’s Accept-Language header value

acceptLanguageItems

fun ApplicationRequest.acceptLanguageItems(): List<HeaderValue>

Parsed and sorted request’s Accept-Language header value

authorization

fun ApplicationRequest.authorization(): String?

Request authorization header value

basicAuthenticationCredentials

fun ApplicationRequest.basicAuthenticationCredentials(
    charset: Charset? = null
): UserPasswordCredential?

Retrieves Basic authentication credentials for this ApplicationRequest

cacheControl

fun ApplicationRequest.cacheControl(): String?

Request’s Cache-Control header value

contentCharset

fun ApplicationRequest.contentCharset(): Charset?

Request’s charset

contentType

fun ApplicationRequest.contentType(): ContentType

Request’s content type or ContentType.Any

decodeChunked

fun CoroutineScope.decodeChunked(
    input: ByteReadChannel
): DecoderJob

Start a chunked stream decoder coroutine

document

fun ApplicationRequest.document(): String

Request’s document name (substring after the last slash but before query string)

embeddedServer

fun <TEngine : ApplicationEngine, TConfiguration : Configuration> CoroutineScope.embeddedServer(
    factory: ApplicationEngineFactory<TEngine, TConfiguration>,
    port: Int = 80,
    host: String = "0.0.0.0",
    watchPaths: List<String> = emptyList(),
    parentCoroutineContext: <ERROR CLASS> = EmptyCoroutineContext,
    configure: TConfiguration.() -> Unit = {},
    module: Application.() -> Unit
): TEngine

Creates an embedded server with the given factory, listening on host:port

header

fun ApplicationRequest.header(name: String): String?

First header value for header with name or null if missing

host

Request’s host without port

httpServer

fun CoroutineScope.httpServer(
    settings: HttpServerSettings,
    handler: HttpRequestHandler
): HttpServer

Start an http server with settings invoking handler for every request

isChunked

fun ApplicationRequest.isChunked(): Boolean

Check if request’s body is chunk-encoded

isMultipart

fun ApplicationRequest.isMultipart(): Boolean

Check if request body is multipart-encoded

location

fun ApplicationRequest.location(): String?

Request’s Location header value

parseAuthorizationHeader

fun ApplicationRequest.parseAuthorizationHeader(): HttpAuthHeader?

Parses an authorization header from a ApplicationRequest returning a HttpAuthHeader.

parseMultipart

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

path

Request’s path without query string

pinger

fun CoroutineScope.pinger(
    outgoing: SendChannel<Frame>,
    period: Duration,
    timeout: Duration,
    pool: ObjectPool<ByteBuffer> = KtorDefaultPool
): SendChannel<Pong>

Launch pinger coroutine on CoroutineScope that is sending ping every specified period to outgoing channel, waiting for and verifying client’s pong frames. It is also handling timeout and sending timeout close frame

fun CoroutineScope.pinger(
    outgoing: SendChannel<Frame>,
    periodMillis: Long,
    timeoutMillis: Long,
    pool: ObjectPool<ByteBuffer> = KtorDefaultPool
): SendChannel<Pong>

Launch pinger coroutine on CoroutineScope that is sending ping every specified periodMillis to outgoing channel, waiting for and verifying client’s pong frames. It is also handling timeoutMillis and sending timeout close frame

ponger

fun CoroutineScope.ponger(
    outgoing: SendChannel<Pong>,
    pool: ObjectPool<ByteBuffer> = KtorDefaultPool
): SendChannel<Ping>

Launch a ponger actor job on the CoroutineScope sending pongs to outgoing channel. It is acting for every client’s ping frame and replying with corresponding pong

port

Request’s port extracted from Host header value

queryString

fun ApplicationRequest.queryString(): String

Request’s query string or empty string if missing

ranges

Parsed request’s Range header value

startConnectionPipeline

fun CoroutineScope.startConnectionPipeline(
    input: ByteReadChannel,
    output: ByteWriteChannel,
    timeout: WeakTimeoutQueue,
    handler: HttpRequestHandler
): Job

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

toLogString

fun ApplicationRequest.toLogString(): String

Generates a string representing this ApplicationRequest suitable for logging

userAgent

fun ApplicationRequest.userAgent(): String?

Request’s User-Agent header value

writeMultipleRanges

fun CoroutineScope.writeMultipleRanges(
    channelProducer: (LongRange) -> ByteReadChannel,
    ranges: List<LongRange>,
    fullLength: Long?,
    boundary: String,
    contentType: String
): ByteReadChannel

Start multirange response writer coroutine