| 7302 | } |
| 7303 | |
| 7304 | static int |
| 7305 | parent_proxy_handler(TSCont contp, TSEvent event, void *edata) |
| 7306 | { |
| 7307 | ParentTest *ptest = nullptr; |
| 7308 | |
| 7309 | CHECK_SPURIOUS_EVENT(contp, event, edata); |
| 7310 | ptest = static_cast<ParentTest *>(TSContDataGet(contp)); |
| 7311 | ink_release_assert(ptest); |
| 7312 | |
| 7313 | TSHttpTxn txnp = static_cast<TSHttpTxn>(edata); |
| 7314 | |
| 7315 | switch (event) { |
| 7316 | case TS_EVENT_HTTP_READ_REQUEST_HDR: |
| 7317 | rprintf(ptest->regtest, "setting synserver parent proxy to %s:%d\n", "127.0.0.1", SYNSERVER_LISTEN_PORT); |
| 7318 | |
| 7319 | // Since we chose a request format with a hostname of trafficserver.apache.org, it won't get |
| 7320 | // sent to the synserver unless we set a parent proxy. |
| 7321 | TSHttpTxnParentProxySet(txnp, "127.0.0.1", SYNSERVER_LISTEN_PORT); |
| 7322 | |
| 7323 | TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, contp); |
| 7324 | TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, contp); |
| 7325 | |
| 7326 | TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SKIP_REMAPPING, true); |
| 7327 | TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); |
| 7328 | break; |
| 7329 | |
| 7330 | case TS_EVENT_TIMEOUT: |
| 7331 | if (*(ptest->pstatus) == REGRESSION_TEST_INPROGRESS) { |
| 7332 | if (ptest->configured) { |
| 7333 | // If we are still in progress, reschedule. |
| 7334 | rprintf(ptest->regtest, "waiting for response\n"); |
| 7335 | TSContScheduleOnPool(contp, 100, TS_THREAD_POOL_NET); |
| 7336 | break; |
| 7337 | } |
| 7338 | |
| 7339 | // This test uses TSHttpTxnParentProxySet() to dynamically set the parent proxy via |
| 7340 | // the API, which works regardless of parent.config configuration. |
| 7341 | |
| 7342 | // Now it is safe to create a request. |
| 7343 | // HTTP_REQUEST_FORMAT11 is a hostname with a no-cache response, so |
| 7344 | // we will need to set the parent to the synserver to get a |
| 7345 | // response. |
| 7346 | char *request = generate_request(11); |
| 7347 | synclient_txn_send_request(ptest->browser, request); |
| 7348 | TSfree(request); |
| 7349 | |
| 7350 | ptest->configured = true; |
| 7351 | |
| 7352 | } else { |
| 7353 | // Otherwise the test completed so clean up. |
| 7354 | TSContDataSet(contp, nullptr); |
| 7355 | delete ptest; |
| 7356 | } |
| 7357 | break; |
| 7358 | |
| 7359 | case TS_EVENT_HTTP_TXN_CLOSE: |
| 7360 | // We expected to pass or fail reading the response header. At this point we must have failed. |
| 7361 | if (*(ptest->pstatus) == REGRESSION_TEST_INPROGRESS) { |
nothing calls this directly
no test coverage detected