Commit ee4732a6 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

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

parent eacd6eee
...@@ -1860,6 +1860,23 @@ int before_frame_send_callback(nghttp2_session *session, ...@@ -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) { ...@@ -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) {
......
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