From 172924457fd3967c03da350c0778030c811af05e Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 15 Nov 2018 10:13:19 +0900 Subject: [PATCH] h2load: Handle HTTP/1 non-final response --- src/h2load_http1_session.cc | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/h2load_http1_session.cc b/src/h2load_http1_session.cc index 645e11ab..e3925b17 100644 --- a/src/h2load_http1_session.cc +++ b/src/h2load_http1_session.cc @@ -70,6 +70,11 @@ namespace { int htp_statuscb(http_parser *htp, const char *at, size_t length) { auto session = static_cast(htp->data); auto client = session->get_client(); + + if (htp->status_code / 100 == 1) { + return 0; + } + client->on_status_code(session->stream_resp_counter_, htp->status_code); return 0; @@ -82,6 +87,10 @@ int htp_msg_completecb(http_parser *htp) { auto session = static_cast(htp->data); auto client = session->get_client(); + if (htp->status_code / 100 == 1) { + return 0; + } + client->final = http_should_keep_alive(htp) == 0; auto req_stat = client->get_req_stat(session->stream_resp_counter_); @@ -133,6 +142,12 @@ int htp_hdr_valcb(http_parser *htp, const char *data, size_t len) { } } // namespace +namespace { +int htp_hdrs_completecb(http_parser *htp) { + return !http2::expect_response_body(htp->status_code); +} +} // namespace + namespace { int htp_body_cb(http_parser *htp, const char *data, size_t len) { auto session = static_cast(htp->data); @@ -147,14 +162,14 @@ int htp_body_cb(http_parser *htp, const char *data, size_t len) { namespace { constexpr http_parser_settings htp_hooks = { - htp_msg_begincb, // http_cb on_message_begin; - nullptr, // http_data_cb on_url; - htp_statuscb, // http_data_cb on_status; - htp_hdr_keycb, // http_data_cb on_header_field; - htp_hdr_valcb, // http_data_cb on_header_value; - nullptr, // http_cb on_headers_complete; - htp_body_cb, // http_data_cb on_body; - htp_msg_completecb // http_cb on_message_complete; + htp_msg_begincb, // http_cb on_message_begin; + nullptr, // http_data_cb on_url; + htp_statuscb, // http_data_cb on_status; + htp_hdr_keycb, // http_data_cb on_header_field; + htp_hdr_valcb, // http_data_cb on_header_value; + htp_hdrs_completecb, // http_cb on_headers_complete; + htp_body_cb, // http_data_cb on_body; + htp_msg_completecb // http_cb on_message_complete; }; } // namespace