Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 21 for addInterceptor (0.21 sec)

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

            chain.proceed(chain.request())
          }
        client =
          client.newBuilder()
            .connectTimeout(Duration.ofSeconds(5))
            .addInterceptor(interceptor1)
            .addInterceptor(interceptor2)
            .build()
        val request1 =
          Request.Builder()
            .url("http://" + TestUtil.UNREACHABLE_ADDRESS_IPV4)
            .build()
        val call = client.newCall(request1)
    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)
  2. samples/guide/src/main/java/okhttp3/recipes/CurrentDateHeader.java

    import okhttp3.Interceptor;
    import okhttp3.OkHttpClient;
    import okhttp3.Request;
    import okhttp3.Response;
    
    public final class CurrentDateHeader {
      private final OkHttpClient client = new OkHttpClient.Builder()
          .addInterceptor(new CurrentDateInterceptor())
          .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: Wed Oct 31 15:32:50 GMT 2018
    - 1.8K bytes
    - Viewed (0)
  3. okhttp-brotli/README.md

    provided Accept-Encoding is not set previously.  Modern web servers
    must choose to return Brotli responses.  n.b. It is not used for
    sending requests.
    
    ```java
    OkHttpClient client = new OkHttpClient.Builder()
      .addInterceptor(BrotliInterceptor.INSTANCE)
      .build();
    ```
    
    ```kotlin
    implementation("com.squareup.okhttp3:okhttp-brotli:4.12.0")
    ```
    
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sun Dec 17 15:34:10 GMT 2023
    - 572 bytes
    - Viewed (0)
  4. docs/features/interceptors.md

    Register an _application_ interceptor by calling `addInterceptor()` on `OkHttpClient.Builder`:
    
    ```java
    OkHttpClient client = new OkHttpClient.Builder()
        .addInterceptor(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)
  5. okhttp-brotli/src/test/java/okhttp3/brotli/BrotliTestMain.kt

     * limitations under the License.
     */
    package okhttp3.brotli
    
    import okhttp3.OkHttpClient
    import okhttp3.Request
    
    fun main() {
      val client =
        OkHttpClient.Builder()
          .addInterceptor(BrotliInterceptor)
          .build()
    
      sendRequest("https://httpbin.org/brotli", client)
      sendRequest("https://httpbin.org/gzip", client)
    }
    
    private fun sendRequest(
      url: String,
      client: OkHttpClient,
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 1.1K bytes
    - Viewed (3)
  6. okhttp-logging-interceptor/README.md

    ```java
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(Level.BASIC);
    OkHttpClient client = new OkHttpClient.Builder()
      .addInterceptor(logging)
      .build();
    ```
    
    You can change the log level at any time by calling `setLevel()`.
    
    To log to a custom location, pass a `Logger` instance to the constructor.
    ```java
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sun Dec 17 15:34:10 GMT 2023
    - 1.3K bytes
    - Viewed (0)
  7. samples/guide/src/main/java/okhttp3/recipes/LoggingInterceptors.java

    public final class LoggingInterceptors {
      private static final Logger logger = Logger.getLogger(LoggingInterceptors.class.getName());
      private final OkHttpClient client = new OkHttpClient.Builder()
          .addInterceptor(new LoggingInterceptor())
          .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: Fri Jan 01 15:55:32 GMT 2016
    - 2K bytes
    - Viewed (0)
  8. 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(
    Java
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat May 25 18:02:55 GMT 2019
    - 3.8K bytes
    - Viewed (0)
  9. samples/guide/src/main/java/okhttp3/recipes/PreemptiveAuth.java

    import okhttp3.Request;
    import okhttp3.Response;
    
    public final class PreemptiveAuth {
      private final OkHttpClient client;
    
      public PreemptiveAuth() {
        client = new OkHttpClient.Builder()
            .addInterceptor(
                new BasicAuthInterceptor("publicobject.com", "jesse", "password1"))
            .build();
      }
    
      public void run() throws Exception {
        Request request = new Request.Builder()
    Java
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Nov 05 07:46:46 GMT 2018
    - 2.1K bytes
    - Viewed (0)
  10. okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.kt

                  else -> chain.proceed(chain.request())
                }
              },
            )
            .addNetworkInterceptor(networkInterceptor)
            .addInterceptor(applicationInterceptor)
            .sslSocketFactory(
              handshakeCertificates.sslSocketFactory(),
              handshakeCertificates.trustManager,
            )
            .hostnameVerifier(hostnameVerifier)
    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)
Back to top