scoop:scoop.http.server:0.1.0
src/http_server_options_builder.scoop
Selected production source · src/http_server_options_builder.scoop
1
package scoop.http.server3
import scoop.http.*4
import scoop.time.Duration5
import scoop.tls.TlsServerContext6
import scoop.http.asyncio.*8
/** Configures one complete value; execution remains explicit. */9
public fun httpServerOptions(10
configure: HttpServerOptionsBuilder.() -> Unit = {}11
): HttpServerOptions {12
val builder = HttpServerOptionsBuilder()13
builder.configure()14
return builder.snapshot()15
}17
public fun HttpServerOptions.copy(18
configure: HttpServerOptionsBuilder.() -> Unit = {}19
): HttpServerOptions {20
val builder = HttpServerOptionsBuilder()21
builder.tls = this.tls22
builder.allowHttp1Fallback = this.allowHttp1Fallback23
builder.allowCleartextHttp2 = this.allowCleartextHttp224
builder.allowTlsHttp2 = this.allowTlsHttp225
builder.maxConnections = this.maxConnections26
builder.maxActiveRequests = this.maxActiveRequests27
builder.maxWebSocketSessions = this.maxWebSocketSessions28
builder.request = this.request29
builder.tlsHandshakeTimeout = this.tlsHandshakeTimeout30
builder.firstRequestHeadTimeout = this.firstRequestHeadTimeout31
builder.http2HeadTimeout = this.http2HeadTimeout32
builder.keepAliveIdleTimeout = this.keepAliveIdleTimeout33
builder.bodyReadIdle = this.bodyReadIdle34
builder.responseWriteIdle = this.responseWriteIdle35
builder.gracefulShutdownTimeout = this.gracefulShutdownTimeout36
builder.http1Receive = this.http1Receive37
builder.http1Limits = this.http1Limits38
builder.http2Receive = this.http2Receive39
builder.http2Limits = this.http2Limits40
builder.http2Settings = this.http2Settings41
builder.onWebSocketCompleted = this.onWebSocketCompleted42
builder.onConnectionError = this.onConnectionError43
builder.configure()44
return builder.snapshot()45
}47
public class HttpServerOptionsBuilder internal constructor() {48
public var tls: TlsServerContext? = None49
public var allowHttp1Fallback: Boolean = true50
public var allowCleartextHttp2: Boolean = false51
public var allowTlsHttp2: Boolean = true52
public var maxConnections: Long = 1024L53
public var maxActiveRequests: Long = 256L54
private var configuredMaxWebSocketSessions: Long? = None55
public var maxWebSocketSessions: Long56
get() = configuredMaxWebSocketSessions ?: maxConnections57
set(value) {58
configuredMaxWebSocketSessions = Some(value)59
}60
public var request: HttpRequestOptions = httpRequestOptions()61
public var tlsHandshakeTimeout: Duration? = Some(Duration.seconds(10))62
public var firstRequestHeadTimeout: Duration? = Some(Duration.seconds(10))63
public var http2HeadTimeout: Duration? = Some(Duration.seconds(10))64
public var keepAliveIdleTimeout: Duration? = Some(Duration.seconds(60))65
public var bodyReadIdle: Duration? = Some(Duration.seconds(30))66
public var responseWriteIdle: Duration? = Some(Duration.seconds(30))67
public var gracefulShutdownTimeout: Duration = Duration.seconds(30)68
public var http1Receive: Http1ReceiveOptions = Http1ReceiveOptions()69
public var http1Limits: Http1Limits = Http1Limits()70
public var http2Receive: Http2ReceiveOptions =71
Http2ReceiveOptions(invalidRegularField = Http2InvalidRegularField.RejectStream)72
public var http2Limits: Http2Limits = Http2Limits()73
public var http2Settings: Http2Settings = Http2Settings()74
public var onWebSocketCompleted: ((HttpWebSocketCompletion) -> Unit)? = None75
public var onConnectionError: ((HttpConnectionInfo, Throwable) -> Unit)? = None77
public fun request(configure: HttpRequestOptionsBuilder.() -> Unit): Unit {78
request = request.copy(configure)79
}81
public fun http1Receive(configure: Http1ReceiveOptionsBuilder.() -> Unit): Unit {82
http1Receive = http1Receive.copy(configure)83
}85
public fun http1Limits(configure: Http1LimitsBuilder.() -> Unit): Unit {86
http1Limits = http1Limits.copy(configure)87
}89
public fun http2Receive(configure: Http2ReceiveOptionsBuilder.() -> Unit): Unit {90
http2Receive = http2Receive.copy(configure)91
}93
public fun http2Limits(configure: Http2LimitsBuilder.() -> Unit): Unit {94
http2Limits = http2Limits.copy(configure)95
}97
public fun http2Settings(configure: Http2SettingsBuilder.() -> Unit): Unit {98
http2Settings = http2Settings.copy(configure)99
}100
internal fun snapshot(): HttpServerOptions =101
HttpServerOptions(102
tls,103
allowHttp1Fallback,104
allowCleartextHttp2,105
allowTlsHttp2,106
maxConnections,107
maxActiveRequests,108
maxWebSocketSessions,109
request,110
tlsHandshakeTimeout,111
firstRequestHeadTimeout,112
http2HeadTimeout,113
keepAliveIdleTimeout,114
bodyReadIdle,115
responseWriteIdle,116
gracefulShutdownTimeout,117
http1Receive,118
http1Limits,119
http2Receive,120
http2Limits,121
http2Settings,122
onWebSocketCompleted,123
onConnectionError124
)125
}