* @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 */
| 271 | * @return true - yes, false - no |
| 272 | */ |
| 273 | bool |
| 274 | isResponseGood(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 |
no test coverage detected