WormaCeptor

Ktor Client Plugin

Native Ktor client plugin for capturing HTTP traffic without OkHttp.

Ktor Client Plugin

WormaCeptor provides a native Ktor client plugin for capturing HTTP traffic without OkHttp:

val client = HttpClient(CIO) {
    install(WormaCeptorKtorPlugin) {
        maxContentLength = 500_000L
        retainDataFor = WormaCeptorKtorConfig.RetentionPeriod.ONE_WEEK
        redactHeader("Authorization")
        redactJsonValue("password")
        redactXmlValue("apiKey")
    }
}

Configuration Properties

Property/MethodTypeDefaultDescription
maxContentLengthLong250,000Max body size to capture in bytes
retainDataForRetentionPeriod?nullData retention period (cleanup on plugin install)
redactHeader(name)Method-Delegates to global WormaCeptorApi.redactionConfig
redactBody(pattern)Method-Delegates to global WormaCeptorApi.redactionConfig
redactJsonValue(key)Method-Delegates to global WormaCeptorApi.redactionConfig
redactXmlValue(tag)Method-Delegates to global WormaCeptorApi.redactionConfig

RetentionPeriod Enum

WormaCeptorKtorConfig.RetentionPeriod has the same values as the OkHttp Period enum: ONE_HOUR, ONE_DAY, ONE_WEEK, ONE_MONTH, FOREVER.

Dependency Note

The Ktor plugin classes live in the api-client module. Use compileOnly for the Ktor dependency so it doesn't add Ktor to apps that only use OkHttp:

build.gradle.kts
compileOnly("io.ktor:ktor-client-core:<ktor-version>")

Rate Limiting

Both the OkHttp interceptor and Ktor plugin automatically integrate with the Rate Limiter tool. When rate limiting is enabled in the WormaCeptor UI, artificial latency is applied to network calls.

On this page