diff --git a/src/nghttp.cc b/src/nghttp.cc index c950a111..04869ded 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -484,7 +484,6 @@ int submit_request(HttpClient *client, const Headers &headers, Request *req) { if (expect_continue) { auto timer = std::make_shared(client->loop, req); - timer->start(); req->continue_timer = timer; client->continue_timers.push_back(timer); @@ -1983,6 +1982,35 @@ int before_frame_send_callback(nghttp2_session *session, } // namespace +namespace { +int on_frame_send_callback(nghttp2_session *session, + const nghttp2_frame *frame, + void *user_data) { + if (config.verbose) { + verbose_on_frame_send_callback(session, frame, 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)); + if (!req) { + return 0; + } + + // If this request is using Expect/Continue, start its ContinueTimer. + std::shared_ptr timer = req->continue_timer.lock(); + if (timer) { + timer->start(); + } + + return 0; +} +} // namespace + namespace { int on_frame_not_send_callback(nghttp2_session *session, const nghttp2_frame *frame, int lib_error_code, @@ -2342,9 +2370,6 @@ int run(char **uris, int n) { on_frame_recv_callback2); if (config.verbose) { - nghttp2_session_callbacks_set_on_frame_send_callback( - callbacks, verbose_on_frame_send_callback); - nghttp2_session_callbacks_set_on_invalid_frame_recv_callback( callbacks, verbose_on_invalid_frame_recv_callback); @@ -2364,6 +2389,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_send_callback( + callbacks, on_frame_send_callback); + nghttp2_session_callbacks_set_on_frame_not_send_callback( callbacks, on_frame_not_send_callback);