Hello, I have a question regarding overriding http...
# ktor
d
Hello, I have a question regarding overriding httpclient’s configuration, specifically defaultRequest url param. This is how I set default url.
Copy code
HttpClient(config.engine) {
    configureDefaultRequest(
        defaultUrl = config.defaultUrl,
        defaultHeaders = config.defaultHeaders
    )
}
Is it possible to override default httpclient’s configs (base url specifically), not only for specific request but for all requests or the only way to override it - copy/re-instantiate the client? Lets say, during the init I set
<https://base.url.com>
Copy code
HttpClient(config.engine) {
    defaultRequest {
       url(baseUrl)
    }
}
, a bit later I received new configs and I have to set new base url for all request
<https://new.base.url.com>
. I tried to swap url like this, but It doesn’t have any effects, httpClient still uses old base urls for requests .
Copy code
client.sendPipeline.intercept(HttpSendPipeline.State) {
    context.url(url = newUrl)
}
ty in advance
a
Is it possible to override default httpclient’s configs (base url specifically), not only for specific request but for all requests or the only way to override it - copy/re-instantiate the client?
The only way is to copy/re-instantiate the client because the default request URL is built using the configured block which cannot be mutated.
👍 1
d
@Aleksei Tirman [JB] Ty for quick response