1
0
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:
Goooler
2021-08-28 20:38:04 +08:00
committed by GitHub
parent d06a6e1061
commit f54b300ece
6 changed files with 8 additions and 16 deletions

View File

@@ -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)
}

View File

@@ -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> {
val addresses = Dns.SYSTEM.lookup(hostname)
return listOf(addresses[0])
}
private val SINGLE_INET_ADDRESS_DNS = Dns { hostname ->
val addresses = Dns.SYSTEM.lookup(hostname)
listOf(addresses[0])
}
private operator fun Throwable?.plus(throwable: Throwable): Throwable {

View File

@@ -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

View File

@@ -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?
}

View File

@@ -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
}

View File

@@ -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)