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-4834 Fix startup message on Windows #3157

Merged
merged 2 commits into from Sep 8, 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
2 changes: 1 addition & 1 deletion ktor-client/ktor-client-core/common/test/CookiesTest.kt
Expand Up @@ -43,7 +43,7 @@ class CookiesTest {
}

@Test
fun testCookiesAreRenderedWithSpaceInBetween() = testSuspend{
fun testCookiesAreRenderedWithSpaceInBetween() = testSuspend {
var storage = AcceptAllCookiesStorage()
storage.addCookie("http://localhost/", Cookie("name1", "value1"))
storage.addCookie("http://localhost/", Cookie("name2", "value2"))
Expand Down
Expand Up @@ -402,8 +402,6 @@ class ContentNegotiationTests {
}
}



object Thing

data class StringWrapper(val value: String)
Expand Down
@@ -0,0 +1,15 @@
/*
* 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.engine.internal

private val OS_NAME = System.getProperty("os.name", "")
.lowercase()

internal actual fun escapeHostname(value: String): String {
if (!OS_NAME.contains("windows")) return value
if (value != "0.0.0.0") return value

return "127.0.0.1"
}
Expand Up @@ -72,8 +72,9 @@ public abstract class BaseApplicationEngine(
val log = environment.log
CoroutineScope(environment.application.coroutineContext).launch {
connectors.await().forEach {
val host = escapeHostname(it.host)
log.info(
"Responding at ${it.type.name.lowercase()}://${it.host}:${it.port}"
"Responding at ${it.type.name.lowercase()}://$host:${it.port}"
)
}
}
Expand Down
@@ -0,0 +1,7 @@
/*
* 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.engine.internal

internal expect fun escapeHostname(value: String): String
@@ -0,0 +1,7 @@
/*
* 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.engine.internal

internal actual fun escapeHostname(value: String): String = value