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

Function transformData

plugins/esi/esi.cc:634–899  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632}
633
634static int
635transformData(TSCont contp)
636{
637 ContData *cont_data;
638 int64_t toread, consumed = 0, avail;
639 bool input_vio_buf_null = false;
640 bool process_input_complete = false;
641
642 // Get the output (downstream) vconnection where we'll write data to.
643 cont_data = static_cast<ContData *>(TSContDataGet(contp));
644
645 // If the input VIO's buffer is NULL, we need to terminate the transformation
646 if (!TSVIOBufferGet(cont_data->input_vio)) {
647 input_vio_buf_null = true;
648 if (cont_data->curr_state == ContData::PROCESSING_COMPLETE) {
649 CONT_DATA_DBG(cont_data, "[%s] input_vio NULL, marking transformation to be terminated", __FUNCTION__);
650 return 1;
651 } else if (cont_data->curr_state == ContData::READING_ESI_DOC) {
652 CONT_DATA_DBG(cont_data, "[%s] input_vio NULL while in read state. Assuming end of input", __FUNCTION__);
653 process_input_complete = true;
654 } else {
655 if (!cont_data->data_fetcher->isFetchComplete()) {
656 CONT_DATA_DBG(cont_data, "[%s] input_vio NULL, but data needs to be fetched. Returning control", __FUNCTION__);
657 if (!cont_data->option_info->first_byte_flush) {
658 return 1;
659 }
660 } else {
661 CONT_DATA_DBG(cont_data, "[%s] input_vio NULL, but processing needs to (and can) be completed", __FUNCTION__);
662 }
663 }
664 }
665
666 if (!process_input_complete && (cont_data->curr_state == ContData::READING_ESI_DOC)) {
667 // Determine how much data we have left to read.
668 toread = TSVIONTodoGet(cont_data->input_vio);
669 CONT_DATA_DBG(cont_data, "[%s] upstream VC has %" PRId64 " bytes available to read", __FUNCTION__, toread);
670
671 if (toread > 0) {
672 avail = TSIOBufferReaderAvail(cont_data->input_reader);
673 if (avail == TS_ERROR) {
674 TSError("[esi][%s] Error while getting number of bytes available", __FUNCTION__);
675 return 0;
676 }
677
678 // There are some data available for reading. Let's parse it
679 if (avail > 0) {
680 int64_t data_len;
681 const char *data;
682 TSIOBufferBlock block = TSIOBufferReaderStart(cont_data->input_reader);
683 // Now start extraction
684 while (block != nullptr) {
685 data = TSIOBufferBlockReadStart(block, cont_data->input_reader, &data_len);
686 if (cont_data->input_type == DATA_TYPE_RAW_ESI) {
687 cont_data->esi_proc->addParseData(data, data_len);
688 } else if (cont_data->input_type == DATA_TYPE_GZIPPED_ESI) {
689 string udata = "";
690 cont_data->esi_gunzip->stream_decode(data, data_len, udata);
691 cont_data->esi_proc->addParseData(udata.data(), udata.size());

Callers 1

transformHandlerFunction · 0.85

Calls 15

TSContDataGetFunction · 0.85
TSVIOBufferGetFunction · 0.85
TSVIONTodoGetFunction · 0.85
TSIOBufferReaderAvailFunction · 0.85
TSVIONDoneSetFunction · 0.85
TSVIONDoneGetFunction · 0.85
TSContCallFunction · 0.85
TSVIOContGetFunction · 0.85
removeCacheKeyFunction · 0.85
cacheNodeListFunction · 0.85
gzipFunction · 0.85

Tested by

no test coverage detected