Context
Starting with Kotlin SDK 200.2 there is ability to add http network (application level) interceptor.
Issue
There is no way to modify a request from the chain – there is no builder for it and `Request.Builder()` will cause exception (as it doesn't have okhttp delegate inside).
Sample code
ArcGISEnvironment.configureArcGISHttpClient {
interceptor {
val originalRequest = it.request()
// val newRequest = originalRequest.newBuilder() <-- no API for this op
// it.proceed(newRequest) // so we can't e.g. add/remove header
it.proceed(originalRequest)
}
}
Solved! Go to Solution.
We just released ArcGIS Maps SDK for Kotlin 200.4.0, which supports modification of network requests (headers and parameters) during network request interception, more details here.
Yes, with 200.2.0 we added support for network interceptors, but at this point only for "observational" purposes such as logging network requests. We are currently working on support for modifying network requests as part of network interception. This will be supported in one of the upcoming releases.
Note, if you are interested in adding headers on every outgoing network request, you can currently do this with ArcGISHttpClient.addAdditionalRequestHeader.
Hi @GuntherHeppner , It’s good to hear ArcGIS is gonna support modify request so that we could make the request through internal proxy.
Could you help to give a estimation for the date of next ArcGIS release so that I could plan for my project
The issue with `addAdditionalRequestHeader` is it do adds a header, so there is no way to overwrite the existing one – this is quite critical when e.g. we use own proxy for authorization and every time the auth token expires we have to provide a new header, but the proxy server still expects sole auth header and just uses the first one available (with already expired token).
So we need either interception-with-change-request mechanism or something like `ArcGISHttpClient.removeAdditionalRequestHeader`.
We just released ArcGIS Maps SDK for Kotlin 200.4.0, which supports modification of network requests (headers and parameters) during network request interception, more details here.