ursus
07/12/2025, 2:33 PMHttpClient(OkHttp) {
engine {
preconfigured = okHttpClient
}
install(DefaultRequest) {
url("<http://10.0.2.2:8081/>")
}
install(ContentNegotiation) {
json(json)
}
install(WebSockets)
}
val webSocketSession = ktorClient.webSocketSession("ws")
webSocketSession
doesnt seem to pickup the DefaultRequest
base url
If I duplicate the url again like this
val wsUrl = URLBuilder("<http://10.0.2.2:8081/>")
.apply {
protocol = URLProtocol.WS
path("ws")
}
.buildString()
val webSocketSession = ktorClient.webSocketSession(wsUrl)
then it works
Is that normal? Am I using it wrong?Olivier Patry
07/12/2025, 7:54 PMdefaultRequest {
if (url.host.isEmpty()) {
val defaultUrl = URLBuilder().takeFrom("<http://10.0.2.2:8081>")
url.host = defaultUrl.host
url.port = defaultUrl.port
url.protocol = defaultUrl.protocol
if (!url.encodedPath.startsWith('/')) {
val basePath = defaultUrl.encodedPath
url.encodedPath = "$basePath/${url.encodedPath}"
}
}
}
ursus
07/12/2025, 8:42 PMAleksei Tirman [JB]
07/14/2025, 7:14 AM