Skip to content

Commit

Permalink
fix: use hostname instead of canonicalHostname (#586)
Browse files Browse the repository at this point in the history
Fixes #582.

Co-authored-by: Youssef Bel Mekki <[email protected]>
  • Loading branch information
tronghn and ybelMekk authored Nov 6, 2023
1 parent ca6d5a2 commit f90b563
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ MockWebServerWrapper
val ssl: Ssl? = null,
) : OAuth2HttpServer {
val mockWebServer: MockWebServer = MockWebServer()
private var address: InetAddress? = null

override fun start(
inetAddress: InetAddress,
Expand All @@ -90,6 +91,7 @@ MockWebServerWrapper
if (ssl != null) {
mockWebServer.useHttps(ssl.sslContext().socketFactory, false)
}
this.address = inetAddress
log.debug("started server on address=$inetAddress and port=${mockWebServer.port}, httpsEnabled=${ssl != null}")
}

Expand All @@ -100,7 +102,11 @@ MockWebServerWrapper

override fun port(): Int = mockWebServer.port

override fun url(path: String): HttpUrl = mockWebServer.url(path)
override fun url(path: String): HttpUrl = mockWebServer
.url(path)
.newBuilder()
.host(address?.hostName ?: mockWebServer.hostName)
.build()

override fun sslConfig(): Ssl? = ssl

Expand Down Expand Up @@ -189,7 +195,7 @@ class NettyWrapper
}
return HttpUrl.Builder()
.scheme(scheme)
.host(address.address.canonicalHostName)
.host(address.address.hostName)
.port(port())
.build()
.resolve(path)!!
Expand Down

0 comments on commit f90b563

Please sign in to comment.