X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/ba6b79bd0090077724fa1272ea4d3a31706fcd5a..2c30cf43f1c4ab96f3eca849d7eb4923ffed40b1:/test/interactive-helper/aptwebserver.cc?ds=sidebyside diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index 6a411e24e..950a17bc1 100644 --- a/test/interactive-helper/aptwebserver.cc +++ b/test/interactive-helper/aptwebserver.cc @@ -99,7 +99,7 @@ static void addFileHeaders(std::list &headers, FileFd &data)/*{{{*/ if (_config->FindB("aptwebserver::support::last-modified", true) == true) { std::string lastmodified("Last-Modified: "); - lastmodified.append(TimeRFC1123(data.ModificationTime())); + lastmodified.append(TimeRFC1123(data.ModificationTime(), false)); headers.push_back(lastmodified); } } @@ -122,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) @@ -209,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: "); @@ -245,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:
");
@@ -256,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://");
@@ -329,7 +335,7 @@ static void sendDirectoryListing(int const client, std::string const &dir,/*{{{*
       return;
    }
 
-   listing << "Index of " << dir << ""
+   listing << "Index of " << dir << ""
 	   << "