From ee4732a67699c3f1662295cdfcecc955e00bafc9 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 16 Sep 2015 00:41:55 +0900 Subject: [PATCH] nghttp: Show error if HEADERS frame cannot be sent for whatever reason --- src/nghttp.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/nghttp.cc b/src/nghttp.cc index 5bd9c503..4eb69a60 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -1860,6 +1860,23 @@ int before_frame_send_callback(nghttp2_session *session, } // namespace +namespace { +int on_frame_not_send_callback(nghttp2_session *session, + const nghttp2_frame *frame, int lib_error_code, + void *user_data) { + if (frame->hd.type != NGHTTP2_HEADERS || + frame->headers.cat != NGHTTP2_HCAT_REQUEST) { + return 0; + } + auto req = static_cast( + nghttp2_session_get_stream_user_data(session, frame->hd.stream_id)); + std::cerr << "[ERROR] request " << req->uri + << " failed: " << nghttp2_strerror(lib_error_code) << std::endl; + + return 0; +} +} // namespace + namespace { int on_stream_close_callback(nghttp2_session *session, int32_t stream_id, uint32_t error_code, void *user_data) { @@ -2212,6 +2229,9 @@ int run(char **uris, int n) { nghttp2_session_callbacks_set_before_frame_send_callback( callbacks, before_frame_send_callback); + nghttp2_session_callbacks_set_on_frame_not_send_callback( + callbacks, on_frame_not_send_callback); + nghttp2_session_callbacks_set_send_callback(callbacks, send_callback); if (config.padding) {