Hi all. I'm trying to get a ktor client talking to a REST service that is served via a wifi infrastructure access point on Android. Is there a way to configure an
HttpClient(Android)
with a custom
URLConnection
?
Copy code
val urlConnection: URLConnection = network.openConnection(URL(connection.serverUri))
urlConnection.connect()
val client = HttpClient(Android){
// configure the client to use the url connection from the network
}
a
Aleksei Tirman [JB]
09/20/2024, 8:12 AM
You can configure the
HttpURLConnection
created by Ktor using the requestConfig configuration method.
x
xxfast
09/25/2024, 10:15 PM
Thanks @Aleksei Tirman [JB]. Bit confused about this signature
Copy code
public class AndroidEngineConfig : HttpClientEngineConfig() {
/**
* Allows you to configure [HTTPS](<https://ktor.io/docs/client-ssl.html>) settings for this engine.
*/
public var sslManager: (HttpsURLConnection) -> Unit = {}
/**
* Allows you to set engine-specific request configuration.
*/
public var requestConfig: HttpURLConnection.() -> Unit = {}
}