X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/905fba60a046646a26a56b4c5d4a5dc7d5906f0d..2c30cf43f1c4ab96f3eca849d7eb4923ffed40b1:/test/interactive-helper/aptwebserver.cc?ds=sidebyside diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index 644629a33..950a17bc1 100644 --- a/test/interactive-helper/aptwebserver.cc +++ b/test/interactive-helper/aptwebserver.cc @@ -96,9 +96,12 @@ static void addFileHeaders(std::list &headers, FileFd &data)/*{{{*/ contentlength << "Content-Length: " << data.FileSize(); headers.push_back(contentlength.str()); } - std::string lastmodified("Last-Modified: "); - lastmodified.append(TimeRFC1123(data.ModificationTime())); - headers.push_back(lastmodified); + if (_config->FindB("aptwebserver::support::last-modified", true) == true) + { + std::string lastmodified("Last-Modified: "); + lastmodified.append(TimeRFC1123(data.ModificationTime(), false)); + headers.push_back(lastmodified); + } } /*}}}*/ static void addDataHeaders(std::list &headers, std::string &data)/*{{{*/ @@ -119,13 +122,16 @@ static bool sendHead(int const client, int const httpcode, std::listSet("APTWebserver::Last-Status-Code", httpcode); std::stringstream buffer; + auto const empties = _config->FindVector("aptwebserver::empty-response-header"); + for (auto && e: empties) + buffer << e << ":" << std::endl; _config->Dump(buffer, "aptwebserver::response-header", "%t: %v%n", false); std::vector addheaders = VectorizeString(buffer.str(), '\n'); for (std::vector::const_iterator h = addheaders.begin(); h != addheaders.end(); ++h) headers.push_back(*h); std::string date("Date: "); - date.append(TimeRFC1123(time(NULL))); + date.append(TimeRFC1123(time(NULL), false)); headers.push_back(date); if (chunkedTransferEncoding(headers) == true) @@ -206,8 +212,8 @@ static bool sendData(int const client, std::list const &headers, st static void sendError(int const client, int const httpcode, std::string const &request,/*{{{*/ bool const content, std::string const &error, std::list &headers) { - std::string response(""); - response.append(httpcodeToStr(httpcode)).append(""); + std::string response(""); + response.append(httpcodeToStr(httpcode)).append(""); response.append("

").append(httpcodeToStr(httpcode)).append("

"); if (httpcode != 200) response.append("

Error: "); @@ -242,8 +248,8 @@ static void sendRedirect(int const client, int const httpcode, std::string const std::string const &request, bool content) { std::list headers; - std::string response(""); - response.append(httpcodeToStr(httpcode)).append(""); + std::string response(""); + response.append(httpcodeToStr(httpcode)).append(""); response.append("

").append(httpcodeToStr(httpcode)).append("You should be redirected to ").append(uri).append("

"); response.append("This page is a result of the request:
");
@@ -253,7 +259,10 @@ static void sendRedirect(int const client, int const httpcode, std::string const
    if (strncmp(uri.c_str(), "http://", 7) != 0 && strncmp(uri.c_str(), "https://", 8) != 0)
    {
       std::string const host = LookupTag(request, "Host");
-      if (host.find(":4433") != std::string::npos)
+      unsigned int const httpsport = _config->FindI("aptwebserver::port::https", 4433);
+      std::string hosthttpsport;
+      strprintf(hosthttpsport, ":%u", httpsport);
+      if (host.find(hosthttpsport) != std::string::npos)
 	 location.append("https://");
       else
 	 location.append("http://");
@@ -326,7 +335,7 @@ static void sendDirectoryListing(int const client, std::string const &dir,/*{{{*
       return;
    }
 
-   listing << "Index of " << dir << ""
+   listing << "Index of " << dir << ""
 	   << "