Hi everyone, ```I'm encountering an issue with Kto...
# ktor
s
Hi everyone,
Copy code
I'm encountering an issue with Ktor's HttpClient when setting a default base URL. Here's my setup:
val client = HttpClient(engine) {
    defaultRequest {
        // Setting default base URL for requests
        url("<https://example.com>")
    }
}

When I make a request to a relative path, it works as expected:
client.get {
    url("/sampleApi")
}
// This correctly calls "<https://example.com/sampleApi>"

However, the problem arises when I try to make a request to a different domain with a different protocol:
client.get {
    url("<http://anotherdomain.com/sampleApi>")
}
// This results in "<https://anotherdomain.com/sampleApi>", overriding the protocol to https
The default protocol (https) is being applied to the entire URL, and it changes
http
to
https
for the new domain. Has anyone faced a similar issue or knows how to ensure the protocol specified in the URL remains unchanged? Any help or pointers would be greatly appreciated! Thanks!
b
This is a bug in the default request code that is targeted for 3.0.0 due to some changes in the URL handling https://youtrack.jetbrains.com/issue/KTOR-5586 For a workaround, you might need to use a separate client instance when going from https to http