Skip to content

Commit

Permalink
Merge pull request #824 from kordlib/remove-pipeline-interception
Browse files Browse the repository at this point in the history
Remove no longer needed pipeline interception
  • Loading branch information
DRSchlaubi authored Apr 29, 2023
2 parents 354e5ed + 01de75f commit 1c23d2e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
15 changes: 0 additions & 15 deletions gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import dev.kord.gateway.retry.Retry
import io.ktor.client.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.plugins.websocket.*
import io.ktor.client.request.*
import io.ktor.http.*
import io.ktor.serialization.kotlinx.json.*
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -39,19 +37,6 @@ public class DefaultGatewayBuilder {
val sendRateLimiter = sendRateLimiter ?: IntervalRateLimiter(limit = 120, interval = 60.seconds)
val identifyRateLimiter = identifyRateLimiter ?: IdentifyRateLimiter(maxConcurrency = 1, dispatcher)

client.requestPipeline.intercept(HttpRequestPipeline.Render) {
// CIO adds this header even if no extensions are used, which causes it to be empty
// This immediately kills the gateway connection
if (context.url.protocol.isWebsocket()) {
val header = context.headers[HttpHeaders.SecWebSocketExtensions]
// If it's blank Discord ragequits
if (header?.isBlank() == true) {
context.headers.remove(HttpHeaders.SecWebSocketExtensions)
}
}
proceed()
}

val data = DefaultGatewayData(
url,
client,
Expand Down
15 changes: 0 additions & 15 deletions voice/src/main/kotlin/gateway/DefaultVoiceGatewayBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.plugins.websocket.*
import io.ktor.client.request.*
import io.ktor.http.*
import io.ktor.serialization.kotlinx.json.*
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlin.time.Duration.Companion.seconds
Expand All @@ -33,19 +31,6 @@ public class DefaultVoiceGatewayBuilder(
}
val retry = reconnectRetry ?: LinearRetry(2.seconds, 20.seconds, 10)

client.requestPipeline.intercept(HttpRequestPipeline.Render) {
// CIO adds this header even if no extensions are used, which causes it to be empty
// This immediately kills the gateway connection
if (context.url.protocol.isWebsocket()) {
val header = context.headers[HttpHeaders.SecWebSocketExtensions]
// If it's blank Discord ragequits
if (header?.isBlank() == true) {
context.headers.remove(HttpHeaders.SecWebSocketExtensions)
}
}
proceed()
}

val data = DefaultVoiceGatewayData(
selfId,
guildId,
Expand Down

0 comments on commit 1c23d2e

Please sign in to comment.