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

Method response_buffer_handler

plugins/traffic_dump/transaction_data.cc:51–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49};
50
51int
52TransactionData::response_buffer_handler(TSCont contp, TSEvent event, void * /* edata ATS_UNUSED */)
53{
54 auto *txnData = reinterpret_cast<TransactionData *>(TSContDataGet(contp));
55 // This should always have been set by the TransactionData creator of this Transform.
56 TSAssert(txnData != nullptr);
57
58 // If the virtual connection is closed, we're done.
59 if (TSVConnClosedGet(contp)) {
60 TSContDestroy(contp);
61 return 0;
62 }
63
64 TSVIO input_vio = TSVConnWriteVIOGet(contp);
65
66 switch (event) {
67 case TS_EVENT_ERROR:
68 Dbg(dbg_ctl, "Received an error event reading body data");
69 TSContCall(TSVIOContGet(input_vio), TS_EVENT_ERROR, input_vio);
70 break;
71 case TS_EVENT_VCONN_READ_COMPLETE:
72 break;
73 case TS_EVENT_VCONN_READ_READY:
74 case TS_EVENT_IMMEDIATE:
75 // Look for data and if we find any, consume.
76 if (TSVIOBufferGet(input_vio)) {
77 TSIOBufferReader reader = TSVIOReaderGet(input_vio);
78 int64_t read_avail = TSIOBufferReaderAvail(reader);
79 if (read_avail > 0) {
80 char response_buffer[read_avail];
81 TSIOBufferReaderCopy(reader, response_buffer, read_avail);
82 std::string_view response_bytes{response_buffer, (size_t)read_avail};
83 txnData->_response_body.append(response_bytes);
84
85 TSIOBufferReaderConsume(reader, read_avail);
86 TSVIONDoneSet(input_vio, TSVIONDoneGet(input_vio) + read_avail);
87 Dbg(dbg_ctl, "Consumed %" PRId64 " bytes of response body data", read_avail);
88 }
89 if (TSVIONTodoGet(input_vio) > 0) {
90 // signal that we can accept more data.
91 TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_READY, input_vio);
92 } else {
93 TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_COMPLETE, input_vio);
94 }
95 } else { // There is no buffer.
96 TSError("[%s] upstream buffer disappeared while reading the response body.", debug_tag);
97 }
98 break;
99 default:
100 Dbg(dbg_ctl, "unhandled event %d", event);
101 break;
102 }
103
104 return 0;
105}
106
107void
108TransactionData::initialize_default_sensitive_field()

Callers

nothing calls this directly

Calls 15

TSContDataGetFunction · 0.85
TSVConnClosedGetFunction · 0.85
TSContDestroyFunction · 0.85
TSVConnWriteVIOGetFunction · 0.85
TSContCallFunction · 0.85
TSVIOContGetFunction · 0.85
TSVIOBufferGetFunction · 0.85
TSVIOReaderGetFunction · 0.85
TSIOBufferReaderAvailFunction · 0.85
TSIOBufferReaderCopyFunction · 0.85
TSVIONDoneSetFunction · 0.85
TSVIONDoneGetFunction · 0.85

Tested by

no test coverage detected