////////////////////////////////////////////////////////////////////// create background fetch request if possible
| 70 | // create background fetch request if possible |
| 71 | // |
| 72 | static bool |
| 73 | cont_check_cacheable(TSHttpTxn txnp) |
| 74 | { |
| 75 | if (TSHttpTxnIsInternal(txnp)) { |
| 76 | return false; |
| 77 | } |
| 78 | int lookupStatus; |
| 79 | if (TSHttpTxnCacheLookupStatusGet(txnp, &lookupStatus) == TS_ERROR) { |
| 80 | TSError("[%s] Couldn't get cache status of object", PLUGIN_NAME); |
| 81 | return false; |
| 82 | } |
| 83 | Dbg(dbg_ctl, "lookup status: %s", getCacheLookupResultName(static_cast<TSCacheLookupResult>(lookupStatus))); |
| 84 | bool ret = false; |
| 85 | if (TS_CACHE_LOOKUP_MISS == lookupStatus || TS_CACHE_LOOKUP_HIT_STALE == lookupStatus) { |
| 86 | bool const nostore = TSHttpTxnServerRespNoStoreGet(txnp); |
| 87 | |
| 88 | Dbg(dbg_ctl, "is nostore set %d", nostore); |
| 89 | if (!nostore) { |
| 90 | TSMBuffer request; |
| 91 | TSMLoc req_hdr; |
| 92 | if (TS_SUCCESS == TSHttpTxnClientReqGet(txnp, &request, &req_hdr)) { |
| 93 | BgFetchData *data = new BgFetchData(); |
| 94 | // Initialize the data structure (can fail) and acquire a privileged lock on the URL |
| 95 | if (data->initialize(request, req_hdr, txnp) && data->acquireUrl()) { |
| 96 | Dbg(dbg_ctl, "scheduling background fetch"); |
| 97 | data->schedule(); |
| 98 | ret = true; |
| 99 | } else { |
| 100 | delete data; |
| 101 | } |
| 102 | } |
| 103 | TSHandleMLocRelease(request, TS_NULL_MLOC, req_hdr); |
| 104 | } |
| 105 | } |
| 106 | return ret; |
| 107 | } |
| 108 | |
| 109 | ////////////////////////////////////////////////////////////////////////////// |
| 110 | // Main "plugin", which is a global TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE hook. Before |
no test coverage detected