summaryrefslogtreecommitdiff
path: root/test/interactive-helper
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-07-11 19:11:24 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-07-11 19:11:24 +0200
commit06b3095f81d9a730e8cb95274c8208cb0604cdfe (patch)
tree4fccd74dc51ded3557726954424396417e9795e2 /test/interactive-helper
parent57d13de2fb64a97d1a43d493c253ad2132ffd566 (diff)
add option to send Content-Type based on file extension
Diffstat (limited to 'test/interactive-helper')
-rw-r--r--test/interactive-helper/aptwebserver.cc12
1 files changed, 12 insertions, 0 deletions
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<std::string> &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<std::string> &headers, std::string &data) {/*{{{*/