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 okhttp3.internal.http2.Http2Stream
import mockwebserver3.RecordedRequest import mockwebserver3.RecordedRequest
interface DuplexResponseBody { fun interface DuplexResponseBody {
@Throws(IOException::class) @Throws(IOException::class)
fun onRequest(request: RecordedRequest, http2Stream: Http2Stream) 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 * 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. * fallbacks to prevent the host machine's various IP addresses from interfering.
*/ */
private val SINGLE_INET_ADDRESS_DNS = object : Dns { private val SINGLE_INET_ADDRESS_DNS = Dns { hostname ->
override fun lookup(hostname: String): List<InetAddress> { val addresses = Dns.SYSTEM.lookup(hostname)
val addresses = Dns.SYSTEM.lookup(hostname) listOf(addresses[0])
return listOf(addresses[0])
}
} }
private operator fun Throwable?.plus(throwable: Throwable): Throwable { 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. * 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 * 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 * 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 import java.security.cert.X509Certificate
interface TrustRootIndex { fun interface TrustRootIndex {
/** Returns the trusted CA certificate that signed [cert]. */ /** Returns the trusted CA certificate that signed [cert]. */
fun findByIssuerAndSignature(cert: X509Certificate): X509Certificate? fun findByIssuerAndSignature(cert: X509Certificate): X509Certificate?
} }

View File

@@ -338,9 +338,7 @@ class KotlinSourceModernTest {
@Test @Test
fun dns() { fun dns() {
var dns: Dns = object : Dns { var dns: Dns = Dns { TODO() }
override fun lookup(hostname: String): List<InetAddress> = TODO()
}
val system: Dns = Dns.SYSTEM val system: Dns = Dns.SYSTEM
} }

View File

@@ -90,11 +90,7 @@ class SocketChannelTest(
} }
val client = clientTestRule.newClientBuilder() val client = clientTestRule.newClientBuilder()
.dns(object : Dns { .dns { listOf(InetAddress.getByName("localhost")) }
override fun lookup(hostname: String): List<InetAddress> {
return listOf(InetAddress.getByName("localhost"))
}
})
.callTimeout(4, SECONDS) .callTimeout(4, SECONDS)
.writeTimeout(2, SECONDS) .writeTimeout(2, SECONDS)
.readTimeout(2, SECONDS) .readTimeout(2, SECONDS)