mirror of
https://github.com/square/okhttp.git
synced 2025-08-07 12:42:57 +03:00
Convert SAM (#6828)
This commit is contained in:
@@ -19,7 +19,7 @@ import java.io.IOException
|
||||
import okhttp3.internal.http2.Http2Stream
|
||||
import mockwebserver3.RecordedRequest
|
||||
|
||||
interface DuplexResponseBody {
|
||||
fun interface DuplexResponseBody {
|
||||
@Throws(IOException::class)
|
||||
fun onRequest(request: RecordedRequest, http2Stream: Http2Stream)
|
||||
}
|
||||
|
@@ -253,11 +253,9 @@ class OkHttpClientTestRule : BeforeEachCallback, AfterEachCallback {
|
||||
* A network that resolves only one IP address per host. Use this when testing route selection
|
||||
* fallbacks to prevent the host machine's various IP addresses from interfering.
|
||||
*/
|
||||
private val SINGLE_INET_ADDRESS_DNS = object : Dns {
|
||||
override fun lookup(hostname: String): List<InetAddress> {
|
||||
private val SINGLE_INET_ADDRESS_DNS = Dns { hostname ->
|
||||
val addresses = Dns.SYSTEM.lookup(hostname)
|
||||
return listOf(addresses[0])
|
||||
}
|
||||
listOf(addresses[0])
|
||||
}
|
||||
|
||||
private operator fun Throwable?.plus(throwable: Throwable): Throwable {
|
||||
|
@@ -27,7 +27,7 @@ import okhttp3.Dns.Companion.SYSTEM
|
||||
*
|
||||
* Implementations of this interface must be safe for concurrent use.
|
||||
*/
|
||||
interface Dns {
|
||||
fun interface Dns {
|
||||
/**
|
||||
* Returns the IP addresses of `hostname`, in the order they will be attempted by OkHttp. If a
|
||||
* connection to an address fails, OkHttp will retry the connection with the next address until
|
||||
|
@@ -17,7 +17,7 @@ package okhttp3.internal.tls
|
||||
|
||||
import java.security.cert.X509Certificate
|
||||
|
||||
interface TrustRootIndex {
|
||||
fun interface TrustRootIndex {
|
||||
/** Returns the trusted CA certificate that signed [cert]. */
|
||||
fun findByIssuerAndSignature(cert: X509Certificate): X509Certificate?
|
||||
}
|
||||
|
@@ -338,9 +338,7 @@ class KotlinSourceModernTest {
|
||||
|
||||
@Test
|
||||
fun dns() {
|
||||
var dns: Dns = object : Dns {
|
||||
override fun lookup(hostname: String): List<InetAddress> = TODO()
|
||||
}
|
||||
var dns: Dns = Dns { TODO() }
|
||||
|
||||
val system: Dns = Dns.SYSTEM
|
||||
}
|
||||
|
@@ -90,11 +90,7 @@ class SocketChannelTest(
|
||||
}
|
||||
|
||||
val client = clientTestRule.newClientBuilder()
|
||||
.dns(object : Dns {
|
||||
override fun lookup(hostname: String): List<InetAddress> {
|
||||
return listOf(InetAddress.getByName("localhost"))
|
||||
}
|
||||
})
|
||||
.dns { listOf(InetAddress.getByName("localhost")) }
|
||||
.callTimeout(4, SECONDS)
|
||||
.writeTimeout(2, SECONDS)
|
||||
.readTimeout(2, SECONDS)
|
||||
|
Reference in New Issue
Block a user