Skip to content

Commit

Permalink
KTOR-4916 Fix recursion in deflate config (#3193)
Browse files Browse the repository at this point in the history
  • Loading branch information
e5l authored Oct 12, 2022
1 parent a7a9e62 commit 3455bce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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())
}
}

0 comments on commit 3455bce

Please sign in to comment.