Commit ce434d56 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

src: Print header emission with stream_id

Since all headers are not always longer available on one
nghttp2_session_mem_recv call, received headers may be interleaved
with transmission log of the other frames. To make it clear that
each header belongs to which stream, each header is printed with
stream_id.
parent 13820679
......@@ -780,6 +780,7 @@ int on_header_callback(nghttp2_session *session,
{
auto hd = static_cast<Http2Handler*>(user_data);
if(hd->get_config()->verbose) {
print_session_id(hd->session_id());
verbose_on_header_callback(session, frame, name, namelen, value, valuelen,
user_data);
}
......
......@@ -161,10 +161,13 @@ const char* ansi_escend()
}
} // namespace
void print_nv(nghttp2_nv *nva, size_t nvlen)
namespace {
void print_nv(nghttp2_nv *nva, size_t nvlen, bool indent = true)
{
for(auto& nv : http2::sort_nva(nva, nvlen)) {
print_frame_attr_indent();
if(indent) {
print_frame_attr_indent();
}
printf("%s", ansi_esc("\033[1;34m"));
fwrite(nv.name, nv.namelen, 1, stdout);
printf("%s: ", ansi_escend());
......@@ -172,6 +175,7 @@ void print_nv(nghttp2_nv *nva, size_t nvlen)
printf("\n");
}
}
} // namelen
void print_timer()
{
......@@ -351,7 +355,9 @@ int verbose_on_header_callback(nghttp2_session *session,
const_cast<uint8_t*>(name), const_cast<uint8_t*>(value),
static_cast<uint16_t>(namelen), static_cast<uint16_t>(valuelen)
};
print_nv(&nv, 1);
print_timer();
printf(" (stream_id=%d) ", frame->hd.stream_id);
print_nv(&nv, 1, false /* no indent */);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment