| 8456 | }; |
| 8457 | |
| 8458 | static int |
| 8459 | cont_test_handler(TSCont contp, TSEvent event, void *edata) |
| 8460 | { |
| 8461 | TSHttpTxn txnp = static_cast<TSHttpTxn>(edata); |
| 8462 | ConnectTestData *data = nullptr; |
| 8463 | int request_id = -1; |
| 8464 | |
| 8465 | CHECK_SPURIOUS_EVENT(contp, event, edata); |
| 8466 | data = static_cast<ConnectTestData *>(TSContDataGet(contp)); |
| 8467 | |
| 8468 | TSReleaseAssert(data->magic == MAGIC_ALIVE); |
| 8469 | TSReleaseAssert((data->test_case == TEST_CASE_CONNECT_ID1) || (data->test_case == TEST_CASE_CONNECT_ID2)); |
| 8470 | |
| 8471 | Dbg(dbg_ctl_sdk_ut, "Calling cont_test_handler with event %s (%d)", TSHttpEventNameLookup(event), event); |
| 8472 | |
| 8473 | switch (event) { |
| 8474 | case TS_EVENT_HTTP_READ_REQUEST_HDR: |
| 8475 | Dbg(dbg_ctl_sdk_ut, "cont_test_handler: event READ_REQUEST"); |
| 8476 | |
| 8477 | // First make sure we're getting called for either request 9 or txn 10 |
| 8478 | // Otherwise, this is a request sent by another test. do nothing. |
| 8479 | request_id = get_request_id(txnp); |
| 8480 | TSReleaseAssert(request_id != -1); |
| 8481 | |
| 8482 | Dbg(dbg_ctl_sdk_ut, "cont_test_handler: Request id = %d", request_id); |
| 8483 | |
| 8484 | if ((request_id != TEST_CASE_CONNECT_ID1) && (request_id != TEST_CASE_CONNECT_ID2)) { |
| 8485 | Dbg(dbg_ctl_sdk_ut, "This is not an event for this test !"); |
| 8486 | TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); |
| 8487 | goto done; |
| 8488 | } |
| 8489 | |
| 8490 | if ((request_id == TEST_CASE_CONNECT_ID1) && (data->test_case == TEST_CASE_CONNECT_ID1)) { |
| 8491 | Dbg(dbg_ctl_sdk_ut, "Calling TSHttpTxnIntercept"); |
| 8492 | TSHttpTxnIntercept(data->os->accept_cont, txnp); |
| 8493 | } else if ((request_id == TEST_CASE_CONNECT_ID2) && (data->test_case == TEST_CASE_CONNECT_ID2)) { |
| 8494 | Dbg(dbg_ctl_sdk_ut, "Calling TSHttpTxnServerIntercept"); |
| 8495 | TSHttpTxnServerIntercept(data->os->accept_cont, txnp); |
| 8496 | } |
| 8497 | |
| 8498 | TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); |
| 8499 | break; |
| 8500 | |
| 8501 | case TS_EVENT_TIMEOUT: |
| 8502 | /* Browser still waiting the response ? */ |
| 8503 | if (data->browser->status == REQUEST_INPROGRESS) { |
| 8504 | Dbg(dbg_ctl_sdk_ut, "Browser still waiting response..."); |
| 8505 | TSContScheduleOnPool(contp, 25, TS_THREAD_POOL_NET); |
| 8506 | } |
| 8507 | /* Browser got the response */ |
| 8508 | else { |
| 8509 | /* Check if browser response body is the one we expected */ |
| 8510 | char *body_response = get_body_ptr(data->browser->response); |
| 8511 | const char *body_expected; |
| 8512 | if (data->test_case == TEST_CASE_CONNECT_ID1) { |
| 8513 | body_expected = "Body for response 9"; |
| 8514 | } else { |
| 8515 | body_expected = "Body for response 10"; |
nothing calls this directly
no test coverage detected