From bd97886d8ea573854fc9e2f1551f5477f5c0b6b1 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 29 Jan 2017 22:11:33 +0900 Subject: [PATCH] nghttpx: Use stack allocated buffer instead of making std::string --- src/shrpx_https_upstream.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index a878b0f1..7c1cc4ae 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -949,8 +949,9 @@ void HttpsUpstream::error_reply(unsigned int status_code) { output->append("\r\nServer: "); output->append(get_config()->http.server_name); output->append("\r\nContent-Length: "); - auto cl = util::utos(html.size()); - output->append(cl); + std::array intbuf; + output->append(StringRef{std::begin(intbuf), + util::utos(std::begin(intbuf), html.size())}); output->append("\r\nDate: "); auto lgconf = log_config(); lgconf->update_tstamp(std::chrono::system_clock::now()); @@ -1026,11 +1027,14 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) { auto connect_method = req.method == HTTP_CONNECT; auto buf = downstream->get_response_buf(); + std::array intbuf; buf->append("HTTP/"); - buf->append(util::utos(req.http_major)); + buf->append(StringRef{std::begin(intbuf), + util::utos(std::begin(intbuf), req.http_major)}); buf->append('.'); - buf->append(util::utos(req.http_minor)); + buf->append(StringRef{std::begin(intbuf), + util::utos(std::begin(intbuf), req.http_minor)}); buf->append(' '); buf->append(http2::stringify_status(balloc, resp.http_status)); buf->append(' ');