From aa64e7ad3c749ff27ba224d20c694c8169389c38 Mon Sep 17 00:00:00 2001 From: Jacob Champion Date: Tue, 29 Mar 2016 12:41:28 -0700 Subject: [PATCH] nghttp: stop ContinueTimers on response or reset If the stream itself is reset, or the server sends a final response immediately, any Expect/Continue handshake should be cancelled. --- src/nghttp.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/nghttp.cc b/src/nghttp.cc index 04869ded..e3d215ec 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -1708,6 +1708,12 @@ void check_response_header(nghttp2_session *session, Request *req) { req->res_nva.clear(); http2::init_hdidx(req->res_hdidx); return; + } else { + // A final response stops any pending Expect/Continue handshake. + std::shared_ptr timer = req->continue_timer.lock(); + if (timer) { + timer->stop(); + } } if (gzip) { @@ -2044,6 +2050,12 @@ int on_stream_close_callback(nghttp2_session *session, int32_t stream_id, return 0; } + // If this request is using Expect/Continue, stop its ContinueTimer. + std::shared_ptr timer = req->continue_timer.lock(); + if (timer) { + timer->stop(); + } + update_html_parser(client, req, nullptr, 0, 1); ++client->complete;