////////////////////////////////////////////////////////////////////////// Name : HandleCacheOpenReadHit Description: handle result of a cache hit Details : Cache lookup succeeded and resulted in a cache hit. This means that the Accept* and Etags fields also matched. The cache lookup may have resulted in a vector of alternates (since lookup may be based on a url). A different function (
| 2753 | // |
| 2754 | /////////////////////////////////////////////////////////////////////////////// |
| 2755 | void |
| 2756 | HttpTransact::HandleCacheOpenReadHit(State *s) |
| 2757 | { |
| 2758 | bool needs_revalidate = false; |
| 2759 | bool needs_authenticate = false; |
| 2760 | bool needs_cache_auth = false; |
| 2761 | bool server_up = true; |
| 2762 | CacheHTTPInfo *obj; |
| 2763 | |
| 2764 | if (s->api_update_cached_object == HttpTransact::UPDATE_CACHED_OBJECT_CONTINUE) { |
| 2765 | obj = &s->cache_info.object_store; |
| 2766 | ink_assert(obj->valid()); |
| 2767 | } else { |
| 2768 | obj = s->cache_info.object_read; |
| 2769 | } |
| 2770 | |
| 2771 | if (obj == nullptr || !obj->valid()) { |
| 2772 | HandleCacheOpenReadMiss(s); |
| 2773 | return; |
| 2774 | } |
| 2775 | |
| 2776 | // do we have to authenticate with the server before |
| 2777 | // sending back the cached response to the client? |
| 2778 | Authentication_t authentication_needed = AuthenticationNeeded(s->txn_conf, &s->hdr_info.client_request, obj->response_get()); |
| 2779 | |
| 2780 | switch (authentication_needed) { |
| 2781 | case AUTHENTICATION_SUCCESS: |
| 2782 | TxnDbg(dbg_ctl_http_seq, "Authentication not needed"); |
| 2783 | needs_authenticate = false; |
| 2784 | break; |
| 2785 | case AUTHENTICATION_MUST_REVALIDATE: |
| 2786 | SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_METHOD); |
| 2787 | TxnDbg(dbg_ctl_http_seq, "Authentication needed"); |
| 2788 | needs_authenticate = true; |
| 2789 | break; |
| 2790 | case AUTHENTICATION_MUST_PROXY: |
| 2791 | TxnDbg(dbg_ctl_http_seq, "Authentication needed"); |
| 2792 | HandleCacheOpenReadMiss(s); |
| 2793 | return; |
| 2794 | case AUTHENTICATION_CACHE_AUTH: |
| 2795 | TxnDbg(dbg_ctl_http_seq, "Authentication needed for cache_auth_content"); |
| 2796 | needs_authenticate = false; |
| 2797 | needs_cache_auth = true; |
| 2798 | break; |
| 2799 | default: |
| 2800 | ink_assert(!("AuthenticationNeeded has returned unsupported code.")); |
| 2801 | break; |
| 2802 | } |
| 2803 | |
| 2804 | ink_assert(is_cache_hit(s->cache_lookup_result)); |
| 2805 | |
| 2806 | // We'll request a revalidation under one of these conditions: |
| 2807 | // |
| 2808 | // 1. Cache lookup is a hit, but the response is stale |
| 2809 | // 2. The cached object has a "Cache-Control: no-cache" header |
| 2810 | // *and* |
| 2811 | // proxy.config.http.cache.ignore_server_no_cache is set to 0 (i.e don't ignore no cache -- the default setting) |
| 2812 | // |
nothing calls this directly
no test coverage detected