Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KTOR-4916 Fix recursion in deflate config #3193

Merged
merged 1 commit into from Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -173,8 +173,9 @@ public class WebSocketDeflateExtension internal constructor(
* Configure which protocols should send the client.
*/
public fun configureProtocols(block: (protocols: MutableList<WebSocketExtensionHeader>) -> Unit) {
val old = manualConfig
manualConfig = {
manualConfig(it)
old(it)
block(it)
}
}
Expand Down
12 changes: 12 additions & 0 deletions ktor-shared/ktor-websockets/jvm/test/WebSocketDeflateTest.kt
Expand Up @@ -60,4 +60,16 @@ class WebSocketDeflateTest {
assertEquals(extension.incomingNoContextTakeover, false)
assertEquals(extension.outgoingNoContextTakeover, true)
}

@Test
fun testManualConfig() {
val config = WebSocketDeflateExtension.Config()
config.manualConfig(mutableListOf())

config.configureProtocols {
it.add(WebSocketExtensionHeader("permessage-deflate", listOf("client_no_context_takeover")))
}

config.manualConfig(mutableListOf())
}
}