nghttp: Show error if HEADERS frame cannot be sent for whatever reason

This commit is contained in:
Tatsuhiro Tsujikawa 2015-09-16 00:41:55 +09:00
parent eacd6eeed2
commit ee4732a676
1 changed files with 20 additions and 0 deletions

View File

@ -1860,6 +1860,23 @@ int before_frame_send_callback(nghttp2_session *session,
} // namespace } // 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<Request *>(
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 { namespace {
int on_stream_close_callback(nghttp2_session *session, int32_t stream_id, int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
uint32_t error_code, void *user_data) { 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( nghttp2_session_callbacks_set_before_frame_send_callback(
callbacks, 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); nghttp2_session_callbacks_set_send_callback(callbacks, send_callback);
if (config.padding) { if (config.padding) {