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

Remove no longer needed pipeline interception #824

Merged
merged 1 commit into from
Apr 29, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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