Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 21 for addNetworkInterceptor (0.27 sec)

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

      fun staleCoalescedConnection() {
        server.enqueue(MockResponse())
        server.enqueue(MockResponse())
        val connection = AtomicReference<Connection?>()
        client =
          client.newBuilder()
            .addNetworkInterceptor(
              Interceptor { chain: Interceptor.Chain? ->
                connection.set(chain!!.connection())
                chain.proceed(chain.request())
              },
            )
            .build()
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat Jan 20 10:30:28 GMT 2024
    - 18.7K bytes
    - Viewed (0)
  2. okhttp/src/test/java/okhttp3/InterceptorTest.kt

              .message("Intercepted!")
              .body("abc".toResponseBody("text/plain; charset=utf-8".toMediaType()))
              .build()
          }
        client =
          client.newBuilder()
            .addNetworkInterceptor(interceptor)
            .build()
        val request =
          Request.Builder()
            .url(server.url("/"))
            .build()
        assertFailsWith<IllegalStateException> {
          client.newCall(request).execute()
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sun Jan 14 10:20:09 GMT 2024
    - 27.8K bytes
    - Viewed (0)
  3. samples/guide/src/main/java/okhttp3/recipes/CheckHandshake.java

            }
          }
          return chain.proceed(chain.request());
        }
      };
    
      private final OkHttpClient client = new OkHttpClient.Builder()
          .addNetworkInterceptor(CHECK_HANDSHAKE_INTERCEPTOR)
          .build();
    
      public void run() throws Exception {
        Request request = new Request.Builder()
            .url("https://publicobject.com/helloworld.txt")
            .build();
    
    Java
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Apr 15 14:55:09 GMT 2024
    - 2.1K bytes
    - Viewed (0)
  4. okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.kt

        this.server = server
        client =
          OkHttpClient.Builder()
            .addNetworkInterceptor(
              Interceptor { chain ->
                when {
                  extraNetworkInterceptor != null -> extraNetworkInterceptor!!.intercept(chain)
                  else -> chain.proceed(chain.request())
                }
              },
            )
            .addNetworkInterceptor(networkInterceptor)
            .addInterceptor(applicationInterceptor)
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat Apr 06 09:14:38 GMT 2024
    - 37.6K bytes
    - Viewed (0)
  5. samples/guide/src/main/java/okhttp3/recipes/RewriteResponseCacheControl.java

            // can be read from the cache.
            System.out.println("Force cache: true");
            clientForCall = client.newBuilder()
                .addNetworkInterceptor(REWRITE_CACHE_CONTROL_INTERCEPTOR)
                .build();
          } else {
            System.out.println("Force cache: false");
            clientForCall = client;
          }
    
    Java
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat Jan 12 03:31:36 GMT 2019
    - 2.6K bytes
    - Viewed (0)
  6. docs/features/interceptors.md

    ### Network Interceptors
    
    Registering a network interceptor is quite similar. Call `addNetworkInterceptor()` instead of `addInterceptor()`:
    
    ```java
    OkHttpClient client = new OkHttpClient.Builder()
        .addNetworkInterceptor(new LoggingInterceptor())
        .build();
    
    Request request = new Request.Builder()
        .url("http://www.publicobject.com/helloworld.txt")
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sun Feb 06 02:19:09 GMT 2022
    - 8.1K bytes
    - Viewed (0)
  7. samples/guide/src/main/java/okhttp3/recipes/Progress.java

                System.out.format("%d%% done\n", (100 * bytesRead) / contentLength);
              }
            }
          }
        };
    
        OkHttpClient client = new OkHttpClient.Builder()
            .addNetworkInterceptor(chain -> {
              Response originalResponse = chain.proceed(chain.request());
              return originalResponse.newBuilder()
                  .body(new ProgressResponseBody(originalResponse.body(), progressListener))
    Java
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat Jan 12 03:31:36 GMT 2019
    - 3.9K bytes
    - Viewed (0)
  8. okhttp/src/test/java/okhttp3/ConnectionReuseTest.kt

            // Since this test knowingly leaks a connection, avoid using the default shared connection
            // pool, which should remain clean for subsequent tests.
            .connectionPool(ConnectionPool())
            .addNetworkInterceptor(
              Interceptor { chain: Interceptor.Chain? ->
                val response =
                  chain!!.proceed(
                    chain.request(),
                  )
                responsesNotClosed.add(response)
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 12.3K bytes
    - Viewed (0)
  9. okhttp/src/test/java/okhttp3/CallKotlinTest.kt

        // Capture the connection so that we can later make it stale.
        var connection: RealConnection? = null
        client =
          client.newBuilder()
            .addNetworkInterceptor(
              Interceptor { chain ->
                connection = chain.connection() as RealConnection
                chain.proceed(chain.request())
              },
            )
            .build()
    
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat Jan 20 10:30:28 GMT 2024
    - 8.4K bytes
    - Viewed (0)
  10. okhttp/src/test/java/okhttp3/CallHandshakeTest.kt

                        cipherSuites(*cipherSuites.toTypedArray())
                      }
                    }
                    .build(),
                ),
              )
            }
          }
          .addNetworkInterceptor {
            val socket = it.connection()!!.socket() as SSLSocket
    
            handshakeEnabledCipherSuites = socket.enabledCipherSuites.toList()
    
            it.proceed(it.request())
          }
          .build()
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat Jan 20 10:30:28 GMT 2024
    - 11.2K bytes
    - Viewed (0)
Back to top