From: David Kalnischkies Date: Wed, 11 Jul 2012 17:11:24 +0000 (+0200) Subject: add option to send Content-Type based on file extension X-Git-Tag: 0.9.13.exp1ubuntu1~50^2~1 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/06b3095f81d9a730e8cb95274c8208cb0604cdfe add option to send Content-Type based on file extension --- diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index dbc4a19e0..4ef9631b8 100644 --- a/test/interactive-helper/aptwebserver.cc +++ b/test/interactive-helper/aptwebserver.cc @@ -82,6 +82,18 @@ void addFileHeaders(std::list &headers, FileFd &data) { /*{{{*/ std::string lastmodified("Last-Modified: "); lastmodified.append(TimeRFC1123(data.ModificationTime())); headers.push_back(lastmodified); + + std::string const fileext = flExtension(data.Name()); + if (fileext.empty() == false && fileext != data.Name()) { + std::string confcontenttype("aptwebserver::ContentType::"); + confcontenttype.append(fileext); + std::string const contenttype = _config->Find(confcontenttype); + if (contenttype.empty() == false) { + std::string header("Content-Type: "); + header.append(contenttype); + headers.push_back(header); + } + } } /*}}}*/ void addDataHeaders(std::list &headers, std::string &data) {/*{{{*/