From ac11ba32ee937c8af0179cee3e2ce5e03d69f32b Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 24 Dec 2014 00:56:25 +0900 Subject: [PATCH] nghttpd: Use stack allocated array for headers in submit_file_response --- src/HttpServer.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 1e688ce3..1dbbe0c5 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -541,19 +541,21 @@ int Http2Handler::submit_file_response(const std::string &status, auto date_str = cached_date; std::string content_length = util::utos(file_length); std::string last_modified_str; - auto nva = std::vector{ + nghttp2_nv nva[] = { http2::make_nv_ls(":status", status), http2::make_nv_ls("server", NGHTTPD_SERVER), http2::make_nv_ls("content-length", content_length), http2::make_nv_ll("cache-control", "max-age=3600"), http2::make_nv_ls("date", *date_str), + http2::make_nv_ll("", ""), }; + size_t nvlen = 5; if (last_modified != 0) { last_modified_str = util::http_date(last_modified); - nva.push_back(http2::make_nv_ls("last-modified", last_modified_str)); + nva[nvlen++] = http2::make_nv_ls("last-modified", last_modified_str); } - return nghttp2_submit_response(session_, stream->stream_id, nva.data(), - nva.size(), data_prd); + return nghttp2_submit_response(session_, stream->stream_id, nva, nvlen, + data_prd); } int Http2Handler::submit_response(const std::string &status, int32_t stream_id,