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

Function StateAuthProxyReadHeaders

plugins/authproxy/authproxy.cc:501–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501static TSEvent
502StateAuthProxyReadHeaders(AuthRequestContext *auth, void * /* edata ATS_UNUSED */)
503{
504 TSIOBufferBlock blk;
505 ssize_t consumed = 0;
506 bool complete = false;
507
508 AuthLogDebug("reading header data, %u bytes available", (unsigned)TSIOBufferReaderAvail(auth->iobuf.reader));
509
510 for (blk = TSIOBufferReaderStart(auth->iobuf.reader); blk; blk = TSIOBufferBlockNext(blk)) {
511 const char *ptr;
512 const char *end;
513 int64_t nbytes;
514 TSParseResult result;
515
516 ptr = TSIOBufferBlockReadStart(blk, auth->iobuf.reader, &nbytes);
517 if (ptr == nullptr || nbytes == 0) {
518 continue;
519 }
520
521 end = ptr + nbytes;
522 result = TSHttpHdrParseResp(auth->hparser, auth->rheader.buffer, auth->rheader.header, &ptr, end);
523 switch (result) {
524 case TS_PARSE_ERROR:
525 return TS_EVENT_ERROR;
526 case TS_PARSE_DONE:
527 // We consumed the buffer we got minus the remainder.
528 consumed += (nbytes - std::distance(ptr, end));
529 complete = true;
530 break;
531 case TS_PARSE_CONT:
532 consumed += (nbytes - std::distance(ptr, end));
533 break;
534 }
535
536 if (complete) {
537 break;
538 }
539 }
540
541 AuthLogDebug("consuming %u bytes, %u remain", (unsigned)consumed, (unsigned)TSIOBufferReaderAvail(auth->iobuf.reader));
542 TSIOBufferReaderConsume(auth->iobuf.reader, consumed);
543
544 // If the headers are complete, send a completion event.
545 return complete ? TS_EVENT_HTTP_READ_REQUEST_HDR : TS_EVENT_CONTINUE;
546}
547
548static TSEvent
549StateAuthProxyWriteReady(AuthRequestContext *auth, void * /* edata ATS_UNUSED */)

Callers

nothing calls this directly

Calls 6

TSIOBufferReaderAvailFunction · 0.85
TSHttpHdrParseRespFunction · 0.85
TSIOBufferReaderStartFunction · 0.50
TSIOBufferBlockNextFunction · 0.50
TSIOBufferBlockReadStartFunction · 0.50
TSIOBufferReaderConsumeFunction · 0.50

Tested by

no test coverage detected