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

Function parent_proxy_handler

src/api/InkAPITest.cc:7304–7384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7302}
7303
7304static int
7305parent_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) {

Callers

nothing calls this directly

Calls 13

TSContDataGetFunction · 0.85
rprintfFunction · 0.85
TSHttpTxnParentProxySetFunction · 0.85
TSHttpTxnHookAddFunction · 0.85
TSHttpTxnCntlSetFunction · 0.85
TSHttpTxnReenableFunction · 0.85
TSContScheduleOnPoolFunction · 0.85
generate_requestFunction · 0.85
TSfreeFunction · 0.85
TSContDataSetFunction · 0.85
SDK_RPRINTFunction · 0.85

Tested by

no test coverage detected