Commit 961f41d7 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttp, nghttpd: Add trailer header field when sending trailer part

parent 928d3e5f
...@@ -690,12 +690,22 @@ int Http2Handler::submit_file_response(const std::string &status, ...@@ -690,12 +690,22 @@ int Http2Handler::submit_file_response(const std::string &status,
http2::make_nv_ls("content-length", content_length), http2::make_nv_ls("content-length", content_length),
http2::make_nv_ll("cache-control", "max-age=3600"), http2::make_nv_ll("cache-control", "max-age=3600"),
http2::make_nv_ls("date", sessions_->get_cached_date()), http2::make_nv_ls("date", sessions_->get_cached_date()),
http2::make_nv_ll("", "")); http2::make_nv_ll("", ""), http2::make_nv_ll("", ""));
size_t nvlen = 5; size_t nvlen = 5;
if (last_modified != 0) { if (last_modified != 0) {
last_modified_str = util::http_date(last_modified); last_modified_str = util::http_date(last_modified);
nva[nvlen++] = http2::make_nv_ls("last-modified", last_modified_str); nva[nvlen++] = http2::make_nv_ls("last-modified", last_modified_str);
} }
auto &trailer = get_config()->trailer;
std::string trailer_names;
if (!trailer.empty()) {
trailer_names = trailer[0].name;
for (size_t i = 1; i < trailer.size(); ++i) {
trailer_names += ", ";
trailer_names += trailer[i].name;
}
nva[nvlen++] = http2::make_nv_ls("trailer", trailer_names);
}
return nghttp2_submit_response(session_, stream->stream_id, nva.data(), nvlen, return nghttp2_submit_response(session_, stream->stream_id, nva.data(), nvlen,
data_prd); data_prd);
} }
......
...@@ -376,6 +376,16 @@ int submit_request(HttpClient *client, const Headers &headers, Request *req) { ...@@ -376,6 +376,16 @@ int submit_request(HttpClient *client, const Headers &headers, Request *req) {
nva.push_back(http2::make_nv(kv.name, kv.value, kv.no_index)); nva.push_back(http2::make_nv(kv.name, kv.value, kv.no_index));
} }
std::string trailer_names;
if (!config.trailer.empty()) {
trailer_names = config.trailer[0].name;
for (size_t i = 1; i < config.trailer.size(); ++i) {
trailer_names += ", ";
trailer_names += config.trailer[i].name;
}
nva.push_back(http2::make_nv_ls("trailer", trailer_names));
}
auto stream_id = auto stream_id =
nghttp2_submit_request(client->session, &req->pri_spec, nva.data(), nghttp2_submit_request(client->session, &req->pri_spec, nva.data(),
nva.size(), req->data_prd, req); nva.size(), req->data_prd, req);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment