]> git.saurik.com Git - apt.git/commitdiff
add option to send Content-Type based on file extension
authorDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 11 Jul 2012 17:11:24 +0000 (19:11 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 11 Jul 2012 17:11:24 +0000 (19:11 +0200)
test/interactive-helper/aptwebserver.cc

index dbc4a19e0cf04540134361206f312cb633bb6b18..4ef9631b8145446c3357fde34f4f3e1df38859d9 100644 (file)
@@ -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) {/*{{{*/