Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 21 for addInterceptor (0.19 sec)

  1. okhttp/src/test/java/okhttp3/DuplexTest.kt

          MockResponse.Builder()
            .clearHeaders()
            .streamHandler(body)
            .build(),
        )
        client =
          client.newBuilder()
            .addInterceptor(UppercaseRequestInterceptor())
            .addInterceptor(UppercaseResponseInterceptor())
            .build()
        val call =
          client.newCall(
            Request.Builder()
              .url(server.url("/"))
              .post(AsyncRequestBody())
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Sat Jan 20 10:30:28 UTC 2024
    - 23.9K bytes
    - Viewed (0)
  2. okhttp-android/src/test/kotlin/okhttp3/android/AndroidLoggingTest.kt

        val interceptor =
          HttpLoggingInterceptor.androidLogging(tag = "testHttpLoggingInterceptor").apply {
            level = HttpLoggingInterceptor.Level.BASIC
          }
    
        val client = clientBuilder.addInterceptor(interceptor).build()
    
        try {
          client.newCall(request).execute()
        } catch (uhe: UnknownHostException) {
          // expected
        }
    
        val logs = ShadowLog.getLogsForTag("testHttpLoggingInterceptor")
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Mon Apr 01 11:07:32 UTC 2024
    - 3.2K bytes
    - Viewed (0)
  3. samples/guide/src/main/java/okhttp3/recipes/RequestBodyCompression.java

      public static final MediaType MEDIA_TYPE_JSON = MediaType.get("application/json");
    
      private final OkHttpClient client = new OkHttpClient.Builder()
          .addInterceptor(new GzipRequestInterceptor())
          .build();
      private final Moshi moshi = new Moshi.Builder().build();
      private final JsonAdapter<Map<String, String>> mapJsonAdapter = moshi.adapter(
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Sat May 25 18:02:55 UTC 2019
    - 3.8K bytes
    - Viewed (0)
  4. okhttp/src/main/kotlin/okhttp3/OkHttpClient.kt

        fun addInterceptor(interceptor: Interceptor) =
          apply {
            interceptors += interceptor
          }
    
        @JvmName("-addInterceptor") // Prefix with '-' to prevent ambiguous overloads from Java.
        inline fun addInterceptor(crossinline block: (chain: Interceptor.Chain) -> Response) =
          addInterceptor(Interceptor { chain -> block(chain) })
    
        /**
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Sat Apr 06 04:21:33 UTC 2024
    - 52K bytes
    - Viewed (0)
  5. okhttp/src/test/java/okhttp3/internal/ws/WebSocketHttpTest.kt

      private val random = Random(0)
      private var client =
        clientTestRule.newClientBuilder()
          .writeTimeout(Duration.ofMillis(500))
          .readTimeout(Duration.ofMillis(500))
          .addInterceptor(
            Interceptor { chain: Interceptor.Chain ->
              val response = chain.proceed(chain.request())
              // Ensure application interceptors never see a null body.
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Sun Mar 31 17:16:15 UTC 2024
    - 35.2K bytes
    - Viewed (0)
  6. okhttp/src/test/java/okhttp3/OkHttpClientTest.kt

        val interceptor =
          Interceptor { chain: Interceptor.Chain ->
            chain.proceed(chain.request())
          }
        val original = clientTestRule.newClient()
        original.newBuilder()
          .addInterceptor(interceptor)
          .addNetworkInterceptor(interceptor)
          .build()
        assertThat(original.interceptors.size).isEqualTo(0)
        assertThat(original.networkInterceptors.size).isEqualTo(0)
      }
    
      /**
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Sun Mar 31 17:16:15 UTC 2024
    - 13.2K bytes
    - Viewed (0)
  7. okhttp/src/test/java/okhttp3/EventListenerTest.kt

        warmUpCall.execute().use { warmUpResponse -> warmUpResponse.body.string() }
        listener.clearAllEvents()
    
        // Create a client with artificial delays.
        client =
          client.newBuilder()
            .addInterceptor(
              Interceptor { chain: Interceptor.Chain ->
                try {
                  Thread.sleep(applicationInterceptorDelay)
                  return@Interceptor chain.proceed(chain.request())
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Sat Jan 20 10:30:28 UTC 2024
    - 56.9K bytes
    - Viewed (2)
  8. okhttp/src/test/java/okhttp3/CallTest.kt

      @Test
      fun interceptorRecoversWhenRoutesExhausted() {
        server.enqueue(MockResponse(socketPolicy = DisconnectAtStart))
        server.enqueue(MockResponse())
        client =
          client.newBuilder()
            .addInterceptor(
              Interceptor { chain: Interceptor.Chain ->
                try {
                  chain.proceed(chain.request())
                  throw AssertionError()
                } catch (expected: IOException) {
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Wed Apr 10 19:46:48 UTC 2024
    - 142.5K bytes
    - Viewed (0)
  9. okhttp/src/test/java/okhttp3/KotlinSourceModernTest.kt

        builder = builder.connectionSpecs(listOf(ConnectionSpec.MODERN_TLS))
        val interceptors: List<Interceptor> = builder.interceptors()
        builder = builder.addInterceptor(Interceptor { TODO() })
        builder = builder.addInterceptor { it: Interceptor.Chain -> TODO() }
        val networkInterceptors: List<Interceptor> = builder.networkInterceptors()
        builder = builder.addNetworkInterceptor(Interceptor { TODO() })
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Mon Apr 01 14:21:25 UTC 2024
    - 46.5K bytes
    - Viewed (0)
  10. docs/changelogs/changelog_4x.md

        enable [Brotli compression][brotli], which compresses 5-20% smaller than gzip.
    
        ```
        val client = OkHttpClient.Builder()
            .addInterceptor(BrotliInterceptor)
            .build()
        ```
    
        This artifact has a dependency on Google's Brotli decoder (95 KiB).
    
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Wed Apr 17 13:25:31 UTC 2024
    - 25.2K bytes
    - Viewed (0)
Back to top