dns

var dns: Dns?(source)

Specifies the Dns resolver used by the OkHttpClient to look up IP addresses for hostnames. When null, OkHttp's default Dns.SYSTEM resolver is used.

Set this to inject a custom resolver, for example to enable DNS-over-HTTPS or to override host resolution in tests:

install(OkHttp) {
engine {
dns = Dns { hostname -> listOf(InetAddress.getByName("127.0.0.1")) }
}
}

Report a problem