Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 25 for cacheResponse (0.05 sec)

  1. samples/guide/src/main/java/okhttp3/recipes/CacheResponse.java

          System.out.println("Response 2 cache response:    " + response2.cacheResponse());
          System.out.println("Response 2 network response:  " + response2.networkResponse());
        }
    
        System.out.println("Response 2 equals Response 1? " + response1Body.equals(response2Body));
      }
    
      public static void main(String... args) throws Exception {
        new CacheResponse(new File("CacheResponse.tmp")).run();
      }
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Sun May 22 01:29:42 UTC 2016
    - 2.4K bytes
    - Viewed (0)
  2. samples/guide/src/main/java/okhttp3/recipes/kt/CacheResponse.kt

            println("Response 2 cache response:    ${it.cacheResponse}")
            println("Response 2 network response:  ${it.networkResponse}")
            return@use it.body.string()
          }
    
        println("Response 2 equals Response 1? " + (response1Body == response2Body))
      }
    }
    
    fun main() {
      CacheResponse(File("CacheResponse.tmp")).run()
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Wed Mar 19 19:25:20 UTC 2025
    - 2K bytes
    - Viewed (0)
  3. okhttp/src/jvmTest/kotlin/okhttp3/RecordedResponse.kt

      fun assertNoCacheResponse() =
        apply {
          assertThat(response!!.cacheResponse).isNull()
        }
    
      /**
       * Asserts that the current response used the cache and returns the cache response.
       */
      fun cacheResponse(): RecordedResponse {
        val cacheResponse = response!!.cacheResponse!!
        return RecordedResponse(cacheResponse.request, cacheResponse, null, null, null)
      }
    
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Fri Dec 27 13:39:56 UTC 2024
    - 5.3K bytes
    - Viewed (0)
  4. okhttp/src/commonJvmAndroid/kotlin/okhttp3/Response.kt

            checkSupportResponse("networkResponse", networkResponse)
            this.networkResponse = networkResponse
          }
    
        open fun cacheResponse(cacheResponse: Response?) =
          apply {
            checkSupportResponse("cacheResponse", cacheResponse)
            this.cacheResponse = cacheResponse
          }
    
        private fun checkSupportResponse(
          name: String,
          response: Response?,
        ) {
          response?.apply {
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Mon Jul 28 14:39:28 UTC 2025
    - 18.1K bytes
    - Viewed (0)
  5. okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/cache/CacheInterceptor.kt

        if (networkRequest == null) {
          return cacheResponse!!
            .newBuilder()
            .cacheResponse(cacheResponse.stripBody())
            .build()
            .also {
              listener.cacheHit(call, it)
            }
        }
    
        if (cacheResponse != null) {
          listener.cacheConditionalHit(call, cacheResponse)
        } else if (cache != null) {
          listener.cacheMiss(call)
        }
    
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Wed Mar 19 19:25:20 UTC 2025
    - 10.3K bytes
    - Viewed (0)
  6. okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/cache/CacheStrategy.kt

         */
        private fun isFreshnessLifetimeHeuristic(): Boolean = cacheResponse!!.cacheControl.maxAgeSeconds == -1 && expires == null
    
        init {
          if (cacheResponse != null) {
            this.sentRequestMillis = cacheResponse.sentRequestAtMillis
            this.receivedResponseMillis = cacheResponse.receivedResponseAtMillis
            val headers = cacheResponse.headers
            for (i in 0 until headers.size) {
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Wed Mar 19 19:25:20 UTC 2025
    - 12K bytes
    - Viewed (0)
  7. docs/recipes.md

     [CacheResponseJava]: https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/recipes/CacheResponse.java
     [CacheResponseKotlin]: https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/recipes/kt/CacheResponse.kt
     [CancelCallJava]: https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/recipes/CancelCall.java
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Sat Aug 30 17:01:12 UTC 2025
    - 47.8K bytes
    - Viewed (0)
  8. android-test/src/test/kotlin/okhttp/android/test/BaseOkHttpClientUnitTest.kt

        call.execute().use { response ->
          assertThat(response.code).isEqualTo(200)
          assertThat(response.cacheResponse).isNull()
        }
    
        val cachedCall = client.newCall(request)
    
        cachedCall.execute().use { response ->
          assertThat(response.code).isEqualTo(200)
          assertThat(response.cacheResponse).isNotNull()
        }
      }
    
      @Test
      open fun testPublicSuffixDb() {
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Tue Jul 22 20:03:31 UTC 2025
    - 2.3K bytes
    - Viewed (0)
  9. docs/features/caching.md

    received followed by a cache hit or miss.  Critically in the cache hit scenario the server won’t send the response body.
    
    The response will have non-null `cacheResponse` and `networkResponse`. The cacheResponse will be used as the top level
    response only if the response code is HTTP/1.1 304 Not Modified.
     
     - CallStart
     - **CacheConditionalHit**
     - ConnectionAcquired
     - ... Standard Events...
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Sun Feb 06 02:19:09 UTC 2022
    - 3.1K bytes
    - Viewed (0)
  10. okhttp/src/jvmTest/kotlin/okhttp3/KotlinDeprecationErrorTest.kt

        val headers: Headers = response.headers()
        val body: ResponseBody = response.body()
        val networkResponse: Response? = response.networkResponse()
        val cacheResponse: Response? = response.cacheResponse()
        val priorResponse: Response? = response.priorResponse()
        val cacheControl: CacheControl = response.cacheControl()
        val sentRequestAtMillis: Long = response.sentRequestAtMillis()
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Fri Dec 27 13:39:56 UTC 2024
    - 13.3K bytes
    - Viewed (0)
Back to top