Skip to content

Commit

Permalink
KTOR-4827 Fix CIO response delay (#3150)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Vos committed Sep 5, 2022
1 parent b9d20b4 commit 4657cb2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
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)
}

0 comments on commit 4657cb2

Please sign in to comment.