You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/04/25 15:28:18 UTC

[GitHub] [trafficserver] bneradt commented on a diff in pull request #8804: Add support for request body transaction data sink

bneradt commented on code in PR #8804:
URL: https://github.com/apache/trafficserver/pull/8804#discussion_r857757215


##########
example/plugins/c-api/txn_data_sink/txn_data_sink.cc:
##########
@@ -117,43 +117,122 @@ client_reader(TSCont contp, TSEvent event, void *edata)
   return 0;
 }
 
+/** The handler for transaction data sink for response bodies. */
 int
-enable_agent_check(TSHttpTxn txnp)
+response_body_reader(TSCont contp, TSEvent event, void *edata)
 {
-  TSMBuffer req_buf;
-  TSMLoc req_loc;
-  int zret = 0;
+  SinkData *data = static_cast<SinkData *>(TSContDataGet(contp));
+
+  // If we got closed, we're done.
+  if (TSVConnClosedGet(contp)) {
+    delete data;
+    TSContDestroy(contp);
+    return 0;
+  }
+
+  TSVIO input_vio = TSVConnWriteVIOGet(contp);
 
+  if (data == nullptr) {
+    data = new SinkData;
+    TSContDataSet(contp, data);
+  }
+  return body_reader_helper(event, input_vio, data->response_body_bytes);
+}
+
+/** The handler for transaction data sink for request bodies. */
+int
+request_body_reader(TSCont contp, TSEvent event, void *edata)

Review Comment:
   Good point. For the example I think it's probably easier to understand the function as one piece instead of split across three. I consolidated the logic to the single function using a parameter as you suggested.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org