Search Options

Results per page
Sort
Preferred Languages
Advance

Results 51 - 60 of 107 for enqueue (0.22 sec)

  1. docs/contribute/concurrency.md

    #### Do-stuff-later pool
    
    Sometimes there's an action required like calling the application layer or responding to a ping, and the thread discovering the action is not the thread that should do the work. We enqueue a runnable on this executor and it gets handled by one of the executor's threads.
    
    ### Locks
    
    We have 3 different things that we synchronize on.
    
    #### Http2Connection
    
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sun Feb 06 16:35:36 GMT 2022
    - 7K bytes
    - Viewed (0)
  2. samples/guide/src/main/java/okhttp3/recipes/kt/AsynchronousGet.kt

      private val client = OkHttpClient()
    
      fun run() {
        val request =
          Request.Builder()
            .url("http://publicobject.com/helloworld.txt")
            .build()
    
        client.newCall(request).enqueue(
          object : Callback {
            override fun onFailure(
              call: Call,
              e: IOException,
            ) {
              e.printStackTrace()
            }
    
            override fun onResponse(
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 1.6K bytes
    - Viewed (0)
  3. samples/guide/src/main/java/okhttp3/recipes/kt/DevServer.kt

    class DevServer {
      val handshakeCertificates = TlsUtil.localhost()
    
      val server =
        MockWebServer().apply {
          useHttps(handshakeCertificates.sslSocketFactory(), false)
    
          enqueue(
            MockResponse()
              .setResponseCode(HTTP_MOVED_TEMP)
              .setHeader("Location", "https://www.google.com/robots.txt"),
          )
        }
    
      val clientCertificates =
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  4. native-image-tests/src/main/kotlin/okhttp3/SampleTest.kt

      val clientRule = OkHttpClientTestRule()
    
      @Test
      fun passingTest() {
        assertThat("hello").isEqualTo("hello")
      }
    
      @Test
      fun testMockWebServer(server: MockWebServer) {
        server.enqueue(MockResponse(body = "abc"))
    
        val client = clientRule.newClient()
    
        client.newCall(Request(url = server.url("/"))).execute().use {
          assertThat(it.body.string()).isEqualTo("abc")
        }
      }
    
      @Test
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 1.8K bytes
    - Viewed (0)
  5. okhttp-android/src/androidTest/kotlin/okhttp3/android/AndroidAsyncDnsTest.kt

            .build()
    
        serverRule.server.useHttps(localhost.sslSocketFactory())
      }
    
      @Test
      @Ignore("java.net.UnknownHostException: No results for localhost, in CI.")
      fun testRequest() {
        serverRule.server.enqueue(MockResponse())
    
        val call = client.newCall(Request(serverRule.server.url("/")))
    
        call.execute().use { response ->
          assertThat(response.code).isEqualTo(200)
        }
      }
    
      @Test
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 5.7K bytes
    - Viewed (0)
  6. samples/compare/src/test/kotlin/okhttp3/compare/JettyHttpClientTest.kt

      private val client = HttpClient()
    
      @BeforeEach fun setUp() {
        client.start()
      }
    
      @AfterEach fun tearDown() {
        client.stop()
      }
    
      @Test fun get(server: MockWebServer) {
        server.enqueue(MockResponse(body = "hello, Jetty HTTP Client"))
    
        val request =
          client.newRequest(server.url("/").toUri())
            .header("Accept", "text/plain")
        val response = request.send()
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 2K bytes
    - Viewed (0)
  7. docs/features/calls.md

    Calls are executed in one of two ways:
    
     * **Synchronous:** your thread blocks until the response is readable.
     * **Asynchronous:** you enqueue the request on any thread, and get [called back](https://square.github.io/okhttp/4.x/okhttp/okhttp3/-callback/) on another thread when the response is readable.
    
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sun Feb 06 02:19:09 GMT 2022
    - 3.9K bytes
    - Viewed (0)
  8. samples/compare/src/test/kotlin/okhttp3/compare/OkHttpClientTest.kt

    /**
     * OkHttp.
     *
     * https://square.github.io/okhttp/
     */
    class OkHttpClientTest {
      @JvmField @RegisterExtension
      val platform = PlatformRule()
    
      @Test fun get(server: MockWebServer) {
        server.enqueue(MockResponse(body = "hello, OkHttp"))
    
        val client = OkHttpClient()
    
        val request =
          Request.Builder()
            .url(server.url("/"))
            .header("Accept", "text/plain")
            .build()
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 1.8K bytes
    - Viewed (0)
  9. okhttp-sse/src/main/kotlin/okhttp3/sse/internal/RealEventSource.kt

      private var call: Call? = null
    
      @Volatile private var canceled = false
    
      fun connect(callFactory: Call.Factory) {
        call =
          callFactory.newCall(request).apply {
            enqueue(this@RealEventSource)
          }
      }
    
      override fun onResponse(
        call: Call,
        response: Response,
      ) {
        processResponse(response)
      }
    
      fun processResponse(response: Response) {
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 3.2K bytes
    - Viewed (0)
  10. okhttp/src/test/java/okhttp3/CallHandshakeTest.kt

      @BeforeEach
      fun setup(server: MockWebServer) {
        this.server = server
    
        server.enqueue(MockResponse())
    
        client =
          clientTestRule.newClientBuilder()
            .sslSocketFactory(
              handshakeCertificates.sslSocketFactory(),
              handshakeCertificates.trustManager,
            )
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sat Jan 20 10:30:28 GMT 2024
    - 11.2K bytes
    - Viewed (0)
Back to top