Coverage Report

Created: 2026-10-17 07:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libsoup/libsoup/soup-http2-utils.c
Line
Count
Source
1
/*
2
 * Copyright 2022 Igalia, S.L.
3
 */
4
5
#include <glib.h>
6
7
#include "soup-http2-utils.h"
8
9
const char *
10
soup_http2_io_state_to_string (SoupHTTP2IOState state)
11
0
{
12
0
        switch (state) {
13
0
        case STATE_NONE:
14
0
                return "NONE";
15
0
        case STATE_WRITE_HEADERS:
16
0
                return "WRITE_HEADERS";
17
0
        case STATE_WRITE_DATA:
18
0
                return "WRITE_DATA";
19
0
        case STATE_WRITE_DONE:
20
0
                return "WRITE_DONE";
21
0
        case STATE_READ_HEADERS:
22
0
                return "READ_HEADERS";
23
0
        case STATE_READ_DATA_START:
24
0
                return "READ_DATA_START";
25
0
        case STATE_READ_DATA:
26
0
                return "READ_DATA";
27
0
        case STATE_READ_DONE:
28
0
                return "READ_DONE";
29
0
        }
30
0
        g_assert_not_reached ();
31
0
        return "";
32
0
}
33
34
const char *
35
soup_http2_frame_type_to_string (nghttp2_frame_type type)
36
0
{
37
0
        switch (type) {
38
0
        case NGHTTP2_DATA:
39
0
                return "DATA";
40
0
        case NGHTTP2_HEADERS:
41
0
                return "HEADERS";
42
0
        case NGHTTP2_PRIORITY:
43
0
                return "PRIORITY";
44
0
        case NGHTTP2_RST_STREAM:
45
0
                return "RST_STREAM";
46
0
        case NGHTTP2_SETTINGS:
47
0
                return "SETTINGS";
48
0
        case NGHTTP2_PING:
49
0
                return "PING";
50
0
        case NGHTTP2_GOAWAY:
51
0
                return "GOAWAY";
52
0
        case NGHTTP2_WINDOW_UPDATE:
53
0
                return "WINDOW_UPDATE";
54
        /* LCOV_EXCL_START */
55
0
        case NGHTTP2_PUSH_PROMISE:
56
0
                return "PUSH_PROMISE";
57
0
        case NGHTTP2_CONTINUATION:
58
0
                return "CONTINUATION";
59
0
        case NGHTTP2_ALTSVC:
60
0
                return "ALTSVC";
61
0
        case NGHTTP2_ORIGIN:
62
0
                return "ORIGIN";
63
0
        default:
64
0
                g_warn_if_reached ();
65
0
                return "UNKNOWN";
66
        /* LCOV_EXCL_STOP */
67
0
        }
68
0
}
69
70
const char *
71
soup_http2_headers_category_to_string (nghttp2_headers_category catergory)
72
0
{
73
0
        switch (catergory) {
74
0
        case NGHTTP2_HCAT_REQUEST:
75
0
                return "REQUEST";
76
0
        case NGHTTP2_HCAT_RESPONSE:
77
0
                return "RESPONSE";
78
0
        case NGHTTP2_HCAT_PUSH_RESPONSE:
79
0
                return "PUSH_RESPONSE";
80
0
        case NGHTTP2_HCAT_HEADERS:
81
0
                return "HEADERS";
82
0
        }
83
0
        g_assert_not_reached ();
84
0
        return "";
85
0
}
86
87
G_GNUC_PRINTF(1, 0)
88
static void
89
debug_nghttp2 (const char *format,
90
               va_list     args)
91
0
{
92
0
        char *message;
93
0
        gsize len;
94
95
0
        if (g_log_writer_default_would_drop (G_LOG_LEVEL_DEBUG, "nghttp2"))
96
0
                return;
97
98
0
        message = g_strdup_vprintf (format, args);
99
0
        len = strlen (message);
100
0
        if (len >= 1 && message[len - 1] == '\n')
101
0
                message[len - 1] = '\0';
102
0
        g_log ("nghttp2", G_LOG_LEVEL_DEBUG, "[NGHTTP2] %s", message);
103
0
        g_free (message);
104
0
}
105
106
void
107
soup_http2_debug_init (void)
108
0
{
109
0
        static gsize nghttp2_debug_init = 0;
110
0
        if (g_once_init_enter (&nghttp2_debug_init)) {
111
0
                nghttp2_set_debug_vprintf_callback(debug_nghttp2);
112
0
                g_once_init_leave (&nghttp2_debug_init, 1);
113
0
        }
114
115
0
}