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

Function StateAuthProxySendResponse

plugins/authproxy/authproxy.cc:464–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

462}
463
464static TSEvent
465StateAuthProxySendResponse(AuthRequestContext *auth, void * /* edata ATS_UNUSED */)
466{
467 TSMBuffer mbuf;
468 TSMLoc mhdr;
469 TSHttpStatus status;
470 char msg[128];
471
472 // The auth proxy denied this request. We need to copy the auth proxy
473 // response header to the client response header, then read any available
474 // body data and copy that as well.
475
476 // There's only a client response if the auth proxy sent one. There
477 TSReleaseAssert(TSHttpTxnClientRespGet(auth->txn, &mbuf, &mhdr) == TS_SUCCESS);
478
479 TSReleaseAssert(TSHttpHdrCopy(mbuf, mhdr, auth->rheader.buffer, auth->rheader.header) == TS_SUCCESS);
480
481 status = TSHttpHdrStatusGet(mbuf, mhdr);
482 snprintf(msg, sizeof(msg), "%d %s\n", status, TSHttpHdrReasonLookup(status));
483
484 TSHttpTxnErrorBodySet(auth->txn, TSstrdup(msg), strlen(msg), TSstrdup("text/plain"));
485
486 // We must not whack the content length for HEAD responses, since the
487 // client already knows that there is no body. Forcing content length to
488 // zero breaks hdiutil(1) on macOS
489 if (TS_HTTP_METHOD_HEAD != auth->method) {
490 HttpSetMimeHeader(mbuf, mhdr, TS_MIME_FIELD_CONTENT_LENGTH, 0u);
491 }
492
493 AuthLogDebug("sending auth proxy response for status %d", status);
494
495 TSHandleMLocRelease(mbuf, TS_NULL_MLOC, mhdr);
496 TSHttpTxnReenable(auth->txn, TS_EVENT_HTTP_CONTINUE);
497
498 return TS_EVENT_CONTINUE;
499}
500
501static TSEvent
502StateAuthProxyReadHeaders(AuthRequestContext *auth, void * /* edata ATS_UNUSED */)

Callers

nothing calls this directly

Calls 9

TSHttpTxnClientRespGetFunction · 0.85
TSHttpHdrCopyFunction · 0.85
TSHttpHdrStatusGetFunction · 0.85
TSHttpHdrReasonLookupFunction · 0.85
TSHttpTxnErrorBodySetFunction · 0.85
TSstrdupFunction · 0.85
HttpSetMimeHeaderFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
TSHttpTxnReenableFunction · 0.85

Tested by

no test coverage detected