* @brief Get the cachekey used for the particular object in this transaction. * * @param txnp HTTP transaction structure * @param reqBuffer request TSMBuffer * @param destination string reference to where the result is to be appended. * @return true if success or false if failure */
| 209 | * @return true if success or false if failure |
| 210 | */ |
| 211 | bool |
| 212 | appendCacheKey(const TSHttpTxn txnp, const TSMBuffer reqBuffer, String &key) |
| 213 | { |
| 214 | bool ret = false; |
| 215 | TSMLoc keyLoc = TS_NULL_MLOC; |
| 216 | if (TS_SUCCESS == TSUrlCreate(reqBuffer, &keyLoc)) { |
| 217 | if (TS_SUCCESS == TSHttpTxnCacheLookupUrlGet(txnp, reqBuffer, keyLoc)) { |
| 218 | int urlLen = 0; |
| 219 | char *url = TSUrlStringGet(reqBuffer, keyLoc, &urlLen); |
| 220 | if (nullptr != url) { |
| 221 | key.append(url, urlLen); |
| 222 | PrefetchDebug("cache key: %s", key.c_str()); |
| 223 | TSfree(static_cast<void *>(url)); |
| 224 | ret = true; |
| 225 | } |
| 226 | } else { |
| 227 | PrefetchDebug("Failure lookup up cache url"); |
| 228 | } |
| 229 | TSHandleMLocRelease(reqBuffer, TS_NULL_MLOC, keyLoc); |
| 230 | } else { |
| 231 | PrefetchDebug("Failure creating url"); |
| 232 | } |
| 233 | |
| 234 | if (!ret) { |
| 235 | PrefetchError("failed to get cache key"); |
| 236 | } |
| 237 | return ret; |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * @brief Find out if the object was found fresh in cache. |
no test coverage detected