From 3ca4539f99d6731f3144420a6b6748f8259c063e Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 4 Mar 2014 23:37:42 +0900 Subject: [PATCH] nghttpd: Only emit content-encoding: gzip when error-gzip is on --- src/HttpServer.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 3d2b759d..52fe6a16 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -686,10 +686,13 @@ void prepare_status_response(Request *req, Http2Handler *hd, body += util::utos(hd->get_config()->port); body += ""; body += ""; + + std::vector> 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> 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); }