Module: kamailio
Branch: master
Commit: 11c5ed679193c4cc94957c0a5948e07bfbfcfee9
URL:
https://github.com/kamailio/kamailio/commit/11c5ed679193c4cc94957c0a5948e07…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-04-12T21:59:44+02:00
nghttp2: debug with data content
---
Modified: src/modules/nghttp2/nghttp2_server.c
---
Diff:
https://github.com/kamailio/kamailio/commit/11c5ed679193c4cc94957c0a5948e07…
Patch:
https://github.com/kamailio/kamailio/commit/11c5ed679193c4cc94957c0a5948e07…
---
diff --git a/src/modules/nghttp2/nghttp2_server.c b/src/modules/nghttp2/nghttp2_server.c
index 8c17f847f87..d5153bef0c6 100644
--- a/src/modules/nghttp2/nghttp2_server.c
+++ b/src/modules/nghttp2/nghttp2_server.c
@@ -560,6 +560,27 @@ static int on_frame_recv_callback(
return 0;
}
+/*
+ * The implementation of nghttp2_on_data_chunk_recv_callback type.
+ * - function to get the received body.
+ */
+static int on_data_chunk_recv_callback(nghttp2_session *session, uint8_t flags,
+ int32_t stream_id, const uint8_t *data, size_t len, void *user_data)
+{
+ struct Request *req;
+ (void)flags;
+ (void)user_data;
+
+ req = nghttp2_session_get_stream_user_data(session, stream_id);
+ if(req) {
+ LM_DBG("---------------------------- (DATA chunk) [%lu bytes]\n",
+ (unsigned long int)len);
+ LM_DBG("[[%.*s]]", (int)len, (char *)data);
+ LM_DBG("----------------------------\n");
+ }
+ return 0;
+}
+
static int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
uint32_t error_code, void *user_data)
{
@@ -587,6 +608,9 @@ static void initialize_nghttp2_session(http2_session_data
*session_data)
nghttp2_session_callbacks_set_on_frame_recv_callback(
callbacks, on_frame_recv_callback);
+ nghttp2_session_callbacks_set_on_data_chunk_recv_callback(
+ callbacks, on_data_chunk_recv_callback);
+
nghttp2_session_callbacks_set_on_stream_close_callback(
callbacks, on_stream_close_callback);