Dmitry Danilau
01/19/2024, 8:10 PMHttpClient(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>
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 .
client.sendPipeline.intercept(HttpSendPipeline.State) {
context.url(url = newUrl)
}
ty in advanceAleksei Tirman [JB]
01/22/2024, 7:45 AMIs 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.
Dmitry Danilau
01/22/2024, 7:47 AM