diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index ed26e207..3c0c8d28 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -927,6 +927,10 @@ int Http2Upstream::downstream_read(DownstreamConnection *dconn) { if (rv == SHRPX_ERR_EOF) { return downstream_eof(dconn); } + if (rv == SHRPX_ERR_DCONN_CANCELED) { + downstream->pop_downstream_connection(); + return 0; + } if (rv != 0) { if (rv != SHRPX_ERR_NETWORK) { if (LOG_ENABLED(INFO)) { @@ -1163,8 +1167,10 @@ int Http2Upstream::send_reply(Downstream *downstream, const uint8_t *body, auto status_code_str = util::utos(downstream->get_response_http_status()); auto &headers = downstream->get_response_headers(); + auto nva = std::vector(); // 2 for :status and server - auto nva = std::vector(2 + headers.size()); + nva.reserve(2 + headers.size()); + nva.push_back(http2::make_nv_ls(":status", status_code_str)); for (auto &kv : headers) { diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index 8857c670..f1c0b31a 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -800,6 +800,7 @@ int HttpsUpstream::send_reply(Downstream *downstream, const uint8_t *body, auto status_str = http2::get_status_string(downstream->get_response_http_status()); output->append(status_str.c_str(), status_str.size()); + output->append("\r\n"); for (auto &kv : downstream->get_response_headers()) { if (kv.name.empty() || kv.name[0] == ':') { diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index ee66c228..f8d59ea1 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -600,6 +600,10 @@ int SpdyUpstream::downstream_read(DownstreamConnection *dconn) { if (rv == SHRPX_ERR_EOF) { return downstream_eof(dconn); } + if (rv == SHRPX_ERR_DCONN_CANCELED) { + downstream->pop_downstream_connection(); + return 0; + } if (rv != 0) { if (rv != SHRPX_ERR_NETWORK) { if (LOG_ENABLED(INFO)) { @@ -815,8 +819,9 @@ int SpdyUpstream::send_reply(Downstream *downstream, const uint8_t *body, auto &headers = downstream->get_response_headers(); + auto nva = std::vector(); // 3 for :status, :version and server - auto nva = std::vector(3 + headers.size()); + nva.reserve(3 + headers.size()); nva.push_back(":status"); nva.push_back(status_string.c_str());