MCPcopy Create free account
hub / github.com/apache/trafficserver / isResponseGood

Function isResponseGood

plugins/prefetch/plugin.cc:273–293  ·  view source on GitHub ↗

* @brief Check if the response from origin for N-th object is success (200 and 206) * * and only then schedule a pre-fetch for the next * * @param txnp HTTP transaction structure * @return true - yes, false - no */

Source from the content-addressed store, hash-verified

271 * @return true - yes, false - no
272 */
273bool
274isResponseGood(TSHttpTxn txnp)
275{
276 bool good = false;
277 TSMBuffer respBuffer;
278 TSMLoc respHdrLoc;
279 if (TS_SUCCESS == TSHttpTxnServerRespGet(txnp, &respBuffer, &respHdrLoc)) {
280 TSHttpStatus status = TSHttpHdrStatusGet(respBuffer, respHdrLoc);
281 PrefetchDebug("origin response code: %d", status);
282 if (TS_HTTP_STATUS_PARTIAL_CONTENT == status || TS_HTTP_STATUS_OK == status) {
283 good = true;
284 }
285 /* Release the response MLoc */
286 TSHandleMLocRelease(respBuffer, TS_NULL_MLOC, respHdrLoc);
287 } else {
288 /* Failed to get the origin response, possible cause could be a origin connection problems or timeouts or
289 * a previous plugin could have already prepared the client response w/o going to origin server */
290 PrefetchDebug("failed to get origin response");
291 }
292 return good;
293}
294
295/**
296 * @brief get the pristin URL path

Callers 1

respToTriggerPrefetchFunction · 0.85

Calls 3

TSHttpTxnServerRespGetFunction · 0.85
TSHttpHdrStatusGetFunction · 0.85
TSHandleMLocReleaseFunction · 0.85

Tested by

no test coverage detected