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-4827 Fix CIO response delay #3150

Merged
merged 1 commit into from Sep 5, 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 @@ -5,6 +5,7 @@
package io.ktor.network.sockets

public fun SocketAddress.toJavaAddress(): java.net.SocketAddress {
// Do not read the hostname here because that may trigger a name service reverse lookup.
return address
}

Expand Down
@@ -0,0 +1,13 @@
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.server.cio.backend

import io.ktor.network.sockets.*
import io.ktor.util.network.*

internal actual fun SocketAddress.toNetworkAddress(): NetworkAddress {
// Do not read the hostname here because that may trigger a name service reverse lookup.
return toJavaAddress() as? java.net.InetSocketAddress ?: error("Expected inet socket address")
}
Expand Up @@ -13,7 +13,4 @@ internal val SocketAddress.port: Int
return inetAddress.port
}

internal fun SocketAddress.toNetworkAddress(): NetworkAddress {
val inetAddress = this as? InetSocketAddress ?: error("Expected inet socket address")
return NetworkAddress(inetAddress.hostname, inetAddress.port)
}
internal expect fun SocketAddress.toNetworkAddress(): NetworkAddress
@@ -0,0 +1,13 @@
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.server.cio.backend

import io.ktor.network.sockets.*
import io.ktor.util.network.*

internal actual fun SocketAddress.toNetworkAddress(): NetworkAddress {
val inetAddress = this as? InetSocketAddress ?: error("Expected inet socket address")
return NetworkAddress(inetAddress.hostname, inetAddress.port)
}