nghttpd: Use http2::Headers
This commit is contained in:
parent
189f122dd7
commit
29fcd7c946
|
@ -633,7 +633,7 @@ int Http2Handler::submit_file_response(const std::string& status,
|
||||||
int Http2Handler::submit_response
|
int Http2Handler::submit_response
|
||||||
(const std::string& status,
|
(const std::string& status,
|
||||||
int32_t stream_id,
|
int32_t stream_id,
|
||||||
const std::vector<std::pair<std::string, std::string>>& headers,
|
const Headers& headers,
|
||||||
nghttp2_data_provider *data_prd)
|
nghttp2_data_provider *data_prd)
|
||||||
{
|
{
|
||||||
std::string date_str = util::http_date(time(0));
|
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("server", NGHTTPD_SERVER),
|
||||||
http2::make_nv_ls("date", date_str)
|
http2::make_nv_ls("date", date_str)
|
||||||
};
|
};
|
||||||
for(size_t i = 0; i < headers.size(); ++i) {
|
for(auto& nv : headers) {
|
||||||
nva.push_back(http2::make_nv(headers[i].first, headers[i].second, false));
|
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(),
|
int r = nghttp2_submit_response(session_, stream_id, nva.data(), nva.size(),
|
||||||
data_prd);
|
data_prd);
|
||||||
|
@ -825,7 +825,7 @@ void prepare_status_response(Stream *stream, Http2Handler *hd,
|
||||||
body += "</address>";
|
body += "</address>";
|
||||||
body += "</body></html>";
|
body += "</body></html>";
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> headers;
|
Headers headers;
|
||||||
if(hd->get_config()->error_gzip) {
|
if(hd->get_config()->error_gzip) {
|
||||||
gzFile write_fd = gzdopen(pipefd[1], "w");
|
gzFile write_fd = gzdopen(pipefd[1], "w");
|
||||||
gzwrite(write_fd, body.c_str(), body.size());
|
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 += authority->value;
|
||||||
redirect_url += path;
|
redirect_url += path;
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> headers
|
auto headers = Headers{{"location", redirect_url}};
|
||||||
{{"location", redirect_url}};
|
|
||||||
|
|
||||||
hd->submit_response(status, stream->stream_id, headers, nullptr);
|
hd->submit_response(status, stream->stream_id, headers, nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ public:
|
||||||
int submit_response
|
int submit_response
|
||||||
(const std::string& status,
|
(const std::string& status,
|
||||||
int32_t stream_id,
|
int32_t stream_id,
|
||||||
const std::vector<std::pair<std::string, std::string>>& headers,
|
const Headers& headers,
|
||||||
nghttp2_data_provider *data_prd);
|
nghttp2_data_provider *data_prd);
|
||||||
|
|
||||||
int submit_non_final_response(const std::string& status, int32_t stream_id);
|
int submit_non_final_response(const std::string& status, int32_t stream_id);
|
||||||
|
|
Loading…
Reference in New Issue