diff --git a/ktor-server/ktor-server-cio/jvmAndNix/src/io/ktor/server/cio/CIOApplicationRequest.kt b/ktor-server/ktor-server-cio/jvmAndNix/src/io/ktor/server/cio/CIOApplicationRequest.kt index 6d012a7400..2af3feb2e5 100644 --- a/ktor-server/ktor-server-cio/jvmAndNix/src/io/ktor/server/cio/CIOApplicationRequest.kt +++ b/ktor-server/ktor-server-cio/jvmAndNix/src/io/ktor/server/cio/CIOApplicationRequest.kt @@ -77,14 +77,14 @@ internal class CIOConnectionPoint( override val serverPort: Int get() = hostHeaderValue - ?.substringAfter(":", defaultPort.toString())?.toInt() + ?.substringAfterLast(":", defaultPort.toString())?.toInt() ?: localPort override val localHost: String get() = localNetworkAddress?.hostname ?: "localhost" override val serverHost: String - get() = hostHeaderValue?.substringBefore(":") ?: localHost + get() = hostHeaderValue?.substringBeforeLast(":") ?: localHost override val localAddress: String get() = localNetworkAddress?.address ?: "localhost" diff --git a/ktor-server/ktor-server-netty/jvm/src/io/ktor/server/netty/http1/NettyConnectionPoint.kt b/ktor-server/ktor-server-netty/jvm/src/io/ktor/server/netty/http1/NettyConnectionPoint.kt index eb53c96640..5326321a95 100644 --- a/ktor-server/ktor-server-netty/jvm/src/io/ktor/server/netty/http1/NettyConnectionPoint.kt +++ b/ktor-server/ktor-server-netty/jvm/src/io/ktor/server/netty/http1/NettyConnectionPoint.kt @@ -45,7 +45,7 @@ internal class NettyConnectionPoint( ?: "localhost" override val serverHost: String - get() = request.headers().get(HttpHeaders.Host)?.substringBefore(":") ?: localHost + get() = request.headers().get(HttpHeaders.Host)?.substringBeforeLast(":") ?: localHost override val localAddress: String get() = (context.channel().localAddress() as? InetSocketAddress)?.hostString ?: "localhost" @@ -57,7 +57,7 @@ internal class NettyConnectionPoint( get() = (context.channel().localAddress() as? InetSocketAddress)?.port ?: defaultPort override val serverPort: Int - get() = request.headers().get(HttpHeaders.Host)?.substringAfter(":", defaultPort.toString())?.toInt() + get() = request.headers().get(HttpHeaders.Host)?.substringAfterLast(":", defaultPort.toString())?.toInt() ?: localPort override val remoteHost: String