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-7623 Evaluate trace logs lazily in WebSockets client plugin #4429

Merged
merged 1 commit into from
Oct 29, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.plugins.websocket

Expand Down Expand Up @@ -150,11 +150,11 @@ public class WebSockets internal constructor(

scope.requestPipeline.intercept(HttpRequestPipeline.Render) {
if (!context.url.protocol.isWebsocket()) {
LOGGER.trace("Skipping WebSocket plugin for non-websocket request: ${context.url}")
LOGGER.trace { "Skipping WebSocket plugin for non-websocket request: ${context.url}" }
return@intercept
}

LOGGER.trace("Sending WebSocket request ${context.url}")
LOGGER.trace { "Sending WebSocket request ${context.url}" }
context.setCapability(WebSocketCapability, Unit)

if (extensionsSupported) {
Expand All @@ -170,7 +170,7 @@ public class WebSockets internal constructor(
val requestContent = response.request.content

if (requestContent !is WebSocketContent) {
LOGGER.trace("Skipping non-websocket response from ${context.request.url}: $session")
LOGGER.trace { "Skipping non-websocket response from ${context.request.url}: $requestContent" }
return@intercept
}
if (status != HttpStatusCode.SwitchingProtocols) {
Expand All @@ -180,11 +180,11 @@ public class WebSockets internal constructor(
}
if (session !is WebSocketSession) {
throw WebSocketException(
"Handshake exception, expected `WebSocketSession` content but was $session"
"Handshake exception, expected `WebSocketSession` content but was ${session::class}"
)
}

LOGGER.trace("Receive websocket session from ${context.request.url}: $session")
LOGGER.trace { "Receive websocket session from ${context.request.url}: $session" }

if (plugin.maxFrameSize != Int.MAX_VALUE.toLong()) {
session.maxFrameSize = plugin.maxFrameSize
Expand Down