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

Function handle_server_resp

plugins/slice/server.cc:537–744  ·  view source on GitHub ↗

this is called every time the server has data for us

Source from the content-addressed store, hash-verified

535
536// this is called every time the server has data for us
537void
538handle_server_resp(TSCont contp, TSEvent event, Data *const data)
539{
540 switch (event) {
541 case TS_EVENT_VCONN_READ_READY: {
542 if (data->m_blockstate == BlockState::Passthru) {
543 transfer_all_bytes(data);
544 return;
545 }
546
547 // has block response header been parsed??
548 if (!data->m_server_block_header_parsed) {
549 int64_t consumed = 0;
550 TSIOBufferReader const reader = data->m_upstream.m_read.m_reader;
551 TSVIO const input_vio = data->m_upstream.m_read.m_vio;
552 TSParseResult const res = data->m_resp_hdrmgr.populateFrom(data->m_http_parser, reader, TSHttpHdrParseResp, &consumed);
553
554 TSVIONDoneSet(input_vio, TSVIONDoneGet(input_vio) + consumed);
555
556 // the server response header didn't fit into the input buffer.
557 // wait for more data from upstream
558 if (TS_PARSE_CONT == res) {
559 return;
560 }
561
562 bool headerStat = false;
563
564 if (TS_PARSE_DONE == res) {
565 if (!data->m_server_first_header_parsed) {
566 HeaderState const state = handleFirstServerHeader(data, contp);
567
568 data->m_server_first_header_parsed = true;
569 switch (state) {
570 case HeaderState::Fail:
571 data->m_blockstate = BlockState::Fail;
572 headerStat = false;
573 break;
574 case HeaderState::Passthru: {
575 data->m_blockstate = BlockState::Passthru;
576 transfer_all_bytes(data);
577 DEBUG_LOG("Going into a passthru state");
578 return;
579 } break;
580 case HeaderState::Good:
581 default:
582 headerStat = true;
583 break;
584 }
585 } else {
586 headerStat = handleNextServerHeader(data);
587 }
588
589 data->m_server_block_header_parsed = true;
590 }
591
592 // kill the upstream and allow dnstream to clean up
593 if (!headerStat) {
594 data->m_upstream.abort();

Callers 1

intercept_hookFunction · 0.85

Calls 15

transfer_all_bytesFunction · 0.85
TSVIONDoneSetFunction · 0.85
TSVIONDoneGetFunction · 0.85
handleFirstServerHeaderFunction · 0.85
handleNextServerHeaderFunction · 0.85
TSVIOReenableFunction · 0.85
shutdownFunction · 0.85
request_blockFunction · 0.85
transfer_content_bytesFunction · 0.85
abortFunction · 0.85
TSHttpEventNameLookupFunction · 0.85
firstBlockForMethod · 0.80

Tested by

no test coverage detected