| 462 | } |
| 463 | |
| 464 | static TSEvent |
| 465 | StateAuthProxySendResponse(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 | |
| 501 | static TSEvent |
| 502 | StateAuthProxyReadHeaders(AuthRequestContext *auth, void * /* edata ATS_UNUSED */) |
nothing calls this directly
no test coverage detected