////////////////////////////////////////////////////////////////////////// Name : issue_revalidate Description: Sets cache action and does various bookkeeping Details : The Cache Lookup was hit but the document was stale so after calling build_request, we need setup up the cache action, set the via code, and possibly conditionalize the request The paths that we take to get this code a
| 2440 | // |
| 2441 | /////////////////////////////////////////////////////////////////////////////// |
| 2442 | void |
| 2443 | HttpTransact::issue_revalidate(State *s) |
| 2444 | { |
| 2445 | HTTPHdr *c_resp = find_appropriate_cached_resp(s); |
| 2446 | SET_VIA_STRING(VIA_CACHE_RESULT, VIA_IN_CACHE_STALE); |
| 2447 | ink_assert(GET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP) != ' '); |
| 2448 | |
| 2449 | if (s->www_auth_content == CACHE_AUTH_FRESH) { |
| 2450 | s->hdr_info.server_request.method_set(HTTP_METHOD_HEAD, HTTP_LEN_HEAD); |
| 2451 | // The document is fresh in cache and we just want to see if the |
| 2452 | // the client has the right credentials |
| 2453 | // this cache action is just to get us into the hcoofsr function |
| 2454 | s->cache_info.action = CACHE_DO_UPDATE; |
| 2455 | dump_header(dbg_ctl_http_hdrs, &s->hdr_info.server_request, s->state_machine_id(), "Proxy's Request (Conditionalized)"); |
| 2456 | return; |
| 2457 | } |
| 2458 | |
| 2459 | if (s->cache_info.write_lock_state == CACHE_WL_INIT) { |
| 2460 | // We do a cache lookup for DELETE, PUT and POST requests as well. |
| 2461 | // We must, however, delete the cached copy after forwarding the |
| 2462 | // request to the server. is_cache_response_returnable will ensure |
| 2463 | // that we forward the request. We now specify what the cache |
| 2464 | // action should be when the response is received. |
| 2465 | if (does_method_require_cache_copy_deletion(s->txn_conf, s->method)) { |
| 2466 | s->cache_info.action = CACHE_PREPARE_TO_DELETE; |
| 2467 | TxnDbg(dbg_ctl_http_seq, "cache action: DELETE"); |
| 2468 | } else { |
| 2469 | s->cache_info.action = CACHE_PREPARE_TO_UPDATE; |
| 2470 | TxnDbg(dbg_ctl_http_seq, "cache action: UPDATE"); |
| 2471 | } |
| 2472 | } else { |
| 2473 | // We've looped back around due to missing the write lock |
| 2474 | // for the cache. At this point we want to forget about the cache |
| 2475 | ink_assert(s->cache_info.write_lock_state == CACHE_WL_READ_RETRY); |
| 2476 | s->cache_info.action = CACHE_DO_NO_ACTION; |
| 2477 | return; |
| 2478 | } |
| 2479 | |
| 2480 | // if the document is cached, just send a conditional request to the server |
| 2481 | |
| 2482 | // So the request does not have preconditions. It can, however |
| 2483 | // be a simple GET request with a Pragma:no-cache. As on 8/28/98 |
| 2484 | // we have fixed the whole Reload/Shift-Reload cached copy |
| 2485 | // corruption problem. This means that we can issue a conditional |
| 2486 | // request to the server only if the incoming request has a conditional |
| 2487 | // or the incoming request does NOT have a no-cache header. |
| 2488 | // In other words, if the incoming request is not conditional |
| 2489 | // but has a no-cache header we can not issue an IMS. check for |
| 2490 | // that case here. |
| 2491 | bool no_cache_in_request = false; |
| 2492 | |
| 2493 | if (s->hdr_info.client_request.is_pragma_no_cache_set() || s->hdr_info.client_request.is_cache_control_set(HTTP_VALUE_NO_CACHE)) { |
| 2494 | TxnDbg(dbg_ctl_http_trans, "no-cache header directive in request, folks"); |
| 2495 | no_cache_in_request = true; |
| 2496 | } |
| 2497 | |
| 2498 | if ((!(s->hdr_info.client_request.presence(MIME_PRESENCE_IF_MODIFIED_SINCE))) && |
| 2499 | (!(s->hdr_info.client_request.presence(MIME_PRESENCE_IF_NONE_MATCH))) && (no_cache_in_request == true) && |
nothing calls this directly
no test coverage detected