nghttpd: Only emit content-encoding: gzip when error-gzip is on

This commit is contained in:
Tatsuhiro Tsujikawa 2014-03-04 23:37:42 +09:00
parent ddfa93ff5b
commit 3ca4539f99
1 changed files with 3 additions and 2 deletions

View File

@ -686,10 +686,13 @@ void prepare_status_response(Request *req, Http2Handler *hd,
body += util::utos(hd->get_config()->port);
body += "</address>";
body += "</body></html>";
std::vector<std::pair<std::string, std::string>> headers;
if(hd->get_config()->error_gzip) {
gzFile write_fd = gzdopen(pipefd[1], "w");
gzwrite(write_fd, body.c_str(), body.size());
gzclose(write_fd);
headers.emplace_back("content-encoding", "gzip");
} else {
write(pipefd[1], body.c_str(), body.size());
}
@ -699,8 +702,6 @@ void prepare_status_response(Request *req, Http2Handler *hd,
nghttp2_data_provider data_prd;
data_prd.source.fd = pipefd[0];
data_prd.read_callback = file_read_callback;
std::vector<std::pair<std::string, std::string>> headers;
headers.emplace_back("content-encoding", "gzip");
headers.emplace_back("content-type", "text/html; charset=UTF-8");
hd->submit_response(status, req->stream_id, headers, &data_prd);
}