Skip to content

Commit

Permalink
KTOR-5383 Fix parsing server host and port when using NettyConnection… (
Browse files Browse the repository at this point in the history
#4014)

* KTOR-5383 Fix parsing server host and port when using NettyConnectionPoint and CIOConnectionPoint

(cherry picked from commit d5b4053)
  • Loading branch information
Stexxe authored and e5l committed Apr 5, 2024
1 parent 7d3f6a9 commit df04b16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit df04b16

Please sign in to comment.