Skip to content

Commit

Permalink
nghttp2: debug with data content
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Apr 12, 2024
1 parent 2b8d587 commit 11c5ed6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/modules/nghttp2/nghttp2_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 11c5ed6

Please sign in to comment.