[libsoup] http2: set nghttp2 debug callback
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] http2: set nghttp2 debug callback
- Date: Wed, 19 May 2021 13:32:52 +0000 (UTC)
commit eda41de17ccf4ff344f9e2a59e0c1467e8addffa
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Wed May 19 11:04:59 2021 +0200
http2: set nghttp2 debug callback
To log the debug messages using g_log with domain "nghttp2"
libsoup/http2/soup-client-message-io-http2.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
---
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index 90edcefa..e3a0c647 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -1340,9 +1340,33 @@ static const SoupClientMessageIOFuncs io_funcs = {
soup_client_message_io_http2_is_reusable
};
+static void
+debug_nghttp2 (const char *format,
+ va_list args)
+{
+ char *message;
+ gsize len;
+
+ if (g_log_writer_default_would_drop (G_LOG_LEVEL_DEBUG, "nghttp2"))
+ return;
+
+ message = g_strdup_vprintf (format, args);
+ len = strlen (message);
+ if (len >= 1 && message[len - 1] == '\n')
+ message[len - 1] = '\0';
+ g_log ("nghttp2", G_LOG_LEVEL_DEBUG, "[NGHTTP2] %s", message);
+ g_free (message);
+}
+
static void
soup_client_message_io_http2_init (SoupClientMessageIOHTTP2 *io)
{
+ static gsize nghttp2_debug_init = 0;
+ if (g_once_init_enter (&nghttp2_debug_init)) {
+ nghttp2_set_debug_vprintf_callback(debug_nghttp2);
+ g_once_init_leave (&nghttp2_debug_init, 1);
+ }
+
nghttp2_session_callbacks *callbacks;
NGCHECK (nghttp2_session_callbacks_new (&callbacks));
nghttp2_session_callbacks_set_on_header_callback (callbacks, on_header_callback);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]