src: Output debug data in GOAWAY in printable ascii
Non printable ascii is printed as ".".
This commit is contained in:
parent
6afb7442b5
commit
b143039b60
|
@ -325,6 +325,25 @@ const char* frame_name_ansi_esc(print_type ptype)
|
|||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
std::string ascii_dump(const uint8_t *data, size_t len)
|
||||
{
|
||||
std::string res;
|
||||
|
||||
for(size_t i = 0; i < len; ++i) {
|
||||
auto c = data[i];
|
||||
|
||||
if(c >= 0x20 && c < 0x7f) {
|
||||
res += c;
|
||||
} else {
|
||||
res += ".";
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void print_frame(print_type ptype, const nghttp2_frame *frame)
|
||||
{
|
||||
|
@ -431,7 +450,7 @@ void print_frame(print_type ptype, const nghttp2_frame *frame)
|
|||
strstatus(frame->goaway.error_code),
|
||||
frame->goaway.error_code,
|
||||
static_cast<unsigned int>(frame->goaway.opaque_data_len),
|
||||
util::format_hex(frame->goaway.opaque_data,
|
||||
ascii_dump(frame->goaway.opaque_data,
|
||||
frame->goaway.opaque_data_len).c_str());
|
||||
break;
|
||||
case NGHTTP2_WINDOW_UPDATE:
|
||||
|
|
Loading…
Reference in New Issue