Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 24 for cacheResponse (0.2 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();
      }
    Java
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sun May 22 01:29:42 GMT 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()
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 2K bytes
    - Viewed (2)
  3. okhttp/src/main/kotlin/okhttp3/internal/cache/CacheInterceptor.kt

        // If we don't need the network, we're done.
        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)
        }
    
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Fri Mar 22 07:09:21 GMT 2024
    - 10.2K bytes
    - Viewed (0)
  4. okhttp/src/main/kotlin/okhttp3/internal/cache/CacheStrategy.kt

        private fun isFreshnessLifetimeHeuristic(): Boolean {
          return 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) {
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Apr 15 13:24:48 GMT 2024
    - 12K bytes
    - Viewed (0)
  5. okhttp/src/main/kotlin/okhttp3/internal/-ResponseCommon.kt

    fun Response.Builder.commonCacheResponse(cacheResponse: Response?) =
      apply {
        checkSupportResponse("cacheResponse", cacheResponse)
        this.cacheResponse = cacheResponse
      }
    
    private fun checkSupportResponse(
      name: String,
      response: Response?,
    ) {
      response?.apply {
        require(networkResponse == null) { "$name.networkResponse != null" }
        require(cacheResponse == null) { "$name.cacheResponse != null" }
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Apr 15 13:24:48 GMT 2024
    - 5.2K bytes
    - Viewed (0)
  6. okhttp/src/test/java/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)
      }
    
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 5.3K bytes
    - Viewed (0)
  7. okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/DnsOverHttps.kt

                .cacheControl(onlyIfCached)
                .cacheUrlOverride(cacheUrl)
                .build()
    
            val cacheResponse = client.newCall(cacheRequest).execute()
    
            if (cacheResponse.code != HttpURLConnection.HTTP_GATEWAY_TIMEOUT) {
              return cacheResponse
            }
          } catch (ioe: IOException) {
            // Failures are ignored as we can fallback to the network
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Fri Mar 22 07:09:21 GMT 2024
    - 9.8K bytes
    - Viewed (0)
  8. okhttp/src/main/kotlin/okhttp3/Response.kt

      )
      fun networkResponse(): Response? = networkResponse
    
      @JvmName("-deprecated_cacheResponse")
      @Deprecated(
        message = "moved to val",
        replaceWith = ReplaceWith(expression = "cacheResponse"),
        level = DeprecationLevel.ERROR,
      )
      fun cacheResponse(): Response? = cacheResponse
    
      @JvmName("-deprecated_priorResponse")
      @Deprecated(
        message = "moved to val",
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Tue Jan 23 14:31:42 GMT 2024
    - 15.5K 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...
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sun Feb 06 02:19:09 GMT 2022
    - 3.1K bytes
    - Viewed (0)
  10. okhttp-android/src/test/kotlin/okhttp3/android/RobolectricOkHttpClientTest.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()
        }
      }
    
      private fun assumeNetwork() {
        try {
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Wed Apr 10 19:46:48 GMT 2024
    - 2.5K bytes
    - Viewed (0)
Back to top