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.
This commit is contained in:
Tatsuhiro Tsujikawa 2014-01-28 00:20:48 +09:00
parent 1382067976
commit ce434d56a7
2 changed files with 10 additions and 3 deletions

View File

@ -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);
}

View File

@ -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)) {
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;
}