Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 10 for fakeDns (0.05 seconds)

  1. okhttp-testing-support/src/main/kotlin/okhttp3/FakeDns.kt

      /** Sets the results for `hostname`.  */
      operator fun set(
        hostname: String,
        addresses: List<InetAddress>,
      ): FakeDns {
        hostAddresses[hostname] = addresses
        return this
      }
    
      /** Clears the results for `hostname`.  */
      fun clear(hostname: String): FakeDns {
        hostAddresses.remove(hostname)
        return this
      }
    
      @Throws(UnknownHostException::class)
      fun lookup(
        hostname: String,
    Created: Fri Dec 26 11:42:13 GMT 2025
    - Last Modified: Wed Mar 19 19:25:20 GMT 2025
    - 2.5K bytes
    - Click Count (0)
  2. okhttp/src/jvmTest/kotlin/okhttp3/internal/authenticator/JavaNetAuthenticatorTest.kt

    // Most tests from URLConnectionTest
    class JavaNetAuthenticatorTest {
      private var authenticator = JavaNetAuthenticator()
      private val fakeDns = FakeDns()
      private val recordingAuthenticator = RecordingAuthenticator()
      private val factory =
        TestValueFactory()
          .apply {
            dns = fakeDns
          }
    
      @BeforeEach
      fun setup() {
        Authenticator.setDefault(recordingAuthenticator)
      }
    
      @AfterEach
    Created: Fri Dec 26 11:42:13 GMT 2025
    - Last Modified: Wed Mar 19 19:25:20 GMT 2025
    - 2.7K bytes
    - Click Count (0)
  3. okhttp/src/jvmTest/kotlin/okhttp3/ConnectionListenerTest.kt

        server.enqueue(
          MockResponse(
            code = 301,
            headers = headersOf("Location", "http://www.fakeurl:" + server.port),
          ),
        )
        server.enqueue(MockResponse())
        val dns = FakeDns()
        dns["fakeurl"] = client.dns.lookup(server.hostName)
        dns["www.fakeurl"] = client.dns.lookup(server.hostName)
        client =
          client
            .newBuilder()
            .dns(dns)
            .build()
    Created: Fri Dec 26 11:42:13 GMT 2025
    - Last Modified: Tue Nov 04 18:33:48 GMT 2025
    - 9.7K bytes
    - Click Count (0)
  4. okhttp/src/jvmTest/kotlin/okhttp3/internal/connection/RouteSelectorTest.kt

    import java.net.Proxy
    import java.net.ProxySelector
    import java.net.SocketAddress
    import java.net.URI
    import java.net.UnknownHostException
    import kotlin.test.assertFailsWith
    import okhttp3.Address
    import okhttp3.FakeDns
    import okhttp3.OkHttpClientTestRule
    import okhttp3.Request
    import okhttp3.Route
    import okhttp3.TestValueFactory
    import okhttp3.internal.connection.RouteSelector.Companion.socketHost
    Created: Fri Dec 26 11:42:13 GMT 2025
    - Last Modified: Wed Oct 08 03:50:05 GMT 2025
    - 20.3K bytes
    - Click Count (0)
  5. okhttp/src/jvmTest/kotlin/okhttp3/RouteFailureTest.kt

      @StartStop
      val server2 = MockWebServer()
    
      private var eventRecorder = EventRecorder()
    
      private val handshakeCertificates = platform.localhostHandshakeCertificates()
    
      val dns = FakeDns()
    
      val ipv4 = InetAddress.getByName("203.0.113.1")
      val ipv6 = InetAddress.getByName("2001:db8:ffff:ffff:ffff:ffff:ffff:1")
    
      val refusedStream =
        MockResponse
          .Builder()
    Created: Fri Dec 26 11:42:13 GMT 2025
    - Last Modified: Tue Nov 04 19:13:52 GMT 2025
    - 11.6K bytes
    - Click Count (0)
  6. okhttp/src/jvmTest/kotlin/okhttp3/EventListenerTest.kt

          MockResponse
            .Builder()
            .code(301)
            .setHeader("Location", "http://www.fakeurl:" + server.port)
            .build(),
        )
        server.enqueue(MockResponse())
        val dns = FakeDns()
        dns["fakeurl"] = client.dns.lookup(server.hostName)
        dns["www.fakeurl"] = client.dns.lookup(server.hostName)
        client =
          client
            .newBuilder()
            .dns(dns)
            .build()
    Created: Fri Dec 26 11:42:13 GMT 2025
    - Last Modified: Wed Nov 05 18:28:35 GMT 2025
    - 70.5K bytes
    - Click Count (0)
  7. okhttp/src/jvmTest/kotlin/okhttp3/ConnectionCoalescingTest.kt

      @StartStop
      private val server = MockWebServer()
    
      private lateinit var client: OkHttpClient
      private lateinit var rootCa: HeldCertificate
      private lateinit var certificate: HeldCertificate
      private val dns = FakeDns()
      private lateinit var url: HttpUrl
      private lateinit var serverIps: List<InetAddress>
    
      @BeforeEach
      fun setUp() {
        platform.assumeHttp2Support()
        platform.assumeNotBouncyCastle()
        rootCa =
    Created: Fri Dec 26 11:42:13 GMT 2025
    - Last Modified: Thu Jun 19 11:44:16 GMT 2025
    - 19.1K bytes
    - Click Count (0)
  8. okhttp/src/jvmTest/kotlin/okhttp3/CallTest.kt

        executeSynchronously("/")
          .assertCode(200)
          .assertBody("A")
    
        // Attempt conditional cache validation and a DNS miss.
        client =
          client
            .newBuilder()
            .dns(FakeDns())
            .build()
        executeSynchronously("/").assertFailure(UnknownHostException::class.java)
      }
    
      @Test
      fun redirect() {
        server.enqueue(
          MockResponse(
            code = 301,
    Created: Fri Dec 26 11:42:13 GMT 2025
    - Last Modified: Tue Nov 04 19:13:52 GMT 2025
    - 147.4K bytes
    - Click Count (0)
  9. okhttp/src/jvmTest/kotlin/okhttp3/URLConnectionTest.kt

        )
      }
    
      @Test
      fun invalidHost() {
        // Note that 1234.1.1.1 is an invalid host in a URI, but URL isn't as strict.
        client =
          client
            .newBuilder()
            .dns(FakeDns())
            .build()
        assertFailsWith<UnknownHostException> {
          getResponse(
            Request
              .Builder()
              .url("http://1234.1.1.1/index.html".toHttpUrl())
              .build(),
    Created: Fri Dec 26 11:42:13 GMT 2025
    - Last Modified: Sat Jun 21 20:36:35 GMT 2025
    - 133.2K bytes
    - Click Count (0)
  10. docs/changelogs/changelog_3x.md

        interface will make your code easier to test. When you test code that makes
        HTTP requests, you can use this interface to replace the real `OkHttpClient`
        with your own mocks or fakes.
    
        The interface will also let you use OkHttp's API with another HTTP client's
        implementation. This is useful in sandboxed environments like Google App
        Engine.
    
    Created: Fri Dec 26 11:42:13 GMT 2025
    - Last Modified: Sun Feb 06 14:55:54 GMT 2022
    - 50.8K bytes
    - Click Count (0)
Back to Top