This is the HTTP transaction continuation, which is used for all the HTTP hooks.
| 418 | |
| 419 | // This is the HTTP transaction continuation, which is used for all the HTTP hooks. |
| 420 | int |
| 421 | http_txn_cont(TSCont contp, TSEvent event, void *edata) |
| 422 | { |
| 423 | auto txnp = static_cast<TSHttpTxn>(edata); |
| 424 | auto *context = static_cast<cripts::Context *>(TSContDataGet(contp)); |
| 425 | |
| 426 | // ToDo: We can optimize this once we have header heap generation IDs in place. |
| 427 | context->reset(); // Clears the cached handles to internal ATS data (mloc's etc.) |
| 428 | |
| 429 | switch (event) { |
| 430 | // This is only used for global plugin, sine DoRemap() is handled without a continuation |
| 431 | case TS_EVENT_HTTP_READ_REQUEST_HDR: // 60002 |
| 432 | context->state.hook = TS_HTTP_READ_REQUEST_HDR_HOOK; |
| 433 | if (!context->state.error.Failed()) { |
| 434 | // Call any bundle callbacks that are registered for this hook |
| 435 | if (!context->state.error.Failed() && context->p_instance.Callbacks() & cripts::Callbacks::GLB_READ_REQUEST) { |
| 436 | for (auto &bundle : context->p_instance.bundles) { |
| 437 | if (bundle->Callbacks() & cripts::Callbacks::GLB_READ_REQUEST) { |
| 438 | bundle->doSendRequest(context); |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | CDebug("Entering glb_read_request()"); |
| 443 | wrap_glb_read_request(context, true, CaseArg); |
| 444 | if (context->_urls.request.Modified()) { |
| 445 | context->_urls.request._update(); // Make sure any changes to the request URL is updated |
| 446 | } |
| 447 | } |
| 448 | break; |
| 449 | |
| 450 | case TS_EVENT_HTTP_SEND_REQUEST_HDR: // 60004 |
| 451 | context->state.hook = TS_HTTP_SEND_REQUEST_HDR_HOOK; |
| 452 | if (!context->state.error.Failed()) { |
| 453 | // Call any bundle callbacks that are registered for this hook |
| 454 | if (!context->state.error.Failed() && |
| 455 | context->p_instance.Callbacks() & (cripts::Callbacks::DO_SEND_REQUEST | cripts::Callbacks::GLB_SEND_REQUEST)) { |
| 456 | for (auto &bundle : context->p_instance.bundles) { |
| 457 | if (bundle->Callbacks() & (cripts::Callbacks::DO_SEND_REQUEST | cripts::Callbacks::GLB_SEND_REQUEST)) { |
| 458 | bundle->doSendRequest(context); |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | if (context->state.enabled_hooks & cripts::Callbacks::DO_TXN_CLOSE) { |
| 463 | CDebug("Entering do_send_request()"); |
| 464 | wrap_send_request(context, true, CaseArg); |
| 465 | } else if (context->state.enabled_hooks & cripts::Callbacks::GLB_SEND_REQUEST) { |
| 466 | CDebug("Entering glb_send_request()"); |
| 467 | wrap_glb_send_request(context, true, CaseArg); |
| 468 | } |
| 469 | if (context->_urls.request.Modified()) { |
| 470 | context->_urls.request._update(); // Make sure any changes to the request URL is updated |
| 471 | } |
| 472 | } |
| 473 | break; |
| 474 | |
| 475 | case TS_EVENT_HTTP_READ_RESPONSE_HDR: // 60006 |
| 476 | context->state.hook = TS_HTTP_READ_RESPONSE_HDR_HOOK; |
| 477 | if (!context->state.error.Failed()) { |
nothing calls this directly
no test coverage detected