nghttpd: Use http2::Headers

This commit is contained in:
Tatsuhiro Tsujikawa 2014-11-02 23:33:04 +09:00
parent 189f122dd7
commit 29fcd7c946
2 changed files with 6 additions and 7 deletions

View File

@ -633,7 +633,7 @@ int Http2Handler::submit_file_response(const std::string& status,
int Http2Handler::submit_response
(const std::string& status,
int32_t stream_id,
const std::vector<std::pair<std::string, std::string>>& headers,
const Headers& headers,
nghttp2_data_provider *data_prd)
{
std::string date_str = util::http_date(time(0));
@ -642,8 +642,8 @@ int Http2Handler::submit_response
http2::make_nv_ls("server", NGHTTPD_SERVER),
http2::make_nv_ls("date", date_str)
};
for(size_t i = 0; i < headers.size(); ++i) {
nva.push_back(http2::make_nv(headers[i].first, headers[i].second, false));
for(auto& nv : headers) {
nva.push_back(http2::make_nv(nv.name, nv.value, nv.no_index));
}
int r = nghttp2_submit_response(session_, stream_id, nva.data(), nva.size(),
data_prd);
@ -825,7 +825,7 @@ void prepare_status_response(Stream *stream, Http2Handler *hd,
body += "</address>";
body += "</body></html>";
std::vector<std::pair<std::string, std::string>> headers;
Headers headers;
if(hd->get_config()->error_gzip) {
gzFile write_fd = gzdopen(pipefd[1], "w");
gzwrite(write_fd, body.c_str(), body.size());
@ -868,8 +868,7 @@ void prepare_redirect_response(Stream *stream, Http2Handler *hd,
redirect_url += authority->value;
redirect_url += path;
std::vector<std::pair<std::string, std::string>> headers
{{"location", redirect_url}};
auto headers = Headers{{"location", redirect_url}};
hd->submit_response(status, stream->stream_id, headers, nullptr);
}

View File

@ -125,7 +125,7 @@ public:
int submit_response
(const std::string& status,
int32_t stream_id,
const std::vector<std::pair<std::string, std::string>>& headers,
const Headers& headers,
nghttp2_data_provider *data_prd);
int submit_non_final_response(const std::string& status, int32_t stream_id);