]> git.saurik.com Git - apt.git/blobdiff - test/interactive-helper/aptwebserver.cc
rred: truncate result file before writing to it
[apt.git] / test / interactive-helper / aptwebserver.cc
index 0398a45997b1f2458efb89e9d9f480ecf91156e0..817760ec309e57ecbe1c072d4c98a5b71ab19b56 100644 (file)
@@ -99,7 +99,7 @@ static void addFileHeaders(std::list<std::string> &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);
    }
 }
@@ -128,7 +128,7 @@ static bool sendHead(int const client, int const httpcode, std::list<std::string
       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 +209,8 @@ static bool sendData(int const client, std::list<std::string> 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<std::string> &headers)
 {
-   std::string response("<html><head><title>");
-   response.append(httpcodeToStr(httpcode)).append("</title></head>");
+   std::string response("<!doctype html><html><head><title>");
+   response.append(httpcodeToStr(httpcode)).append("</title><meta charset=\"utf-8\" /></head>");
    response.append("<body><h1>").append(httpcodeToStr(httpcode)).append("</h1>");
    if (httpcode != 200)
       response.append("<p><em>Error</em>: ");
@@ -245,8 +245,8 @@ static void sendRedirect(int const client, int const httpcode, std::string const
                  std::string const &request, bool content)
 {
    std::list<std::string> headers;
-   std::string response("<html><head><title>");
-   response.append(httpcodeToStr(httpcode)).append("</title></head>");
+   std::string response("<!doctype html><html><head><title>");
+   response.append(httpcodeToStr(httpcode)).append("</title><meta charset=\"utf-8\" /></head>");
    response.append("<body><h1>").append(httpcodeToStr(httpcode)).append("</h1");
    response.append("<p>You should be redirected to <em>").append(uri).append("</em></p>");
    response.append("This page is a result of the request: <pre>");
@@ -332,7 +332,7 @@ static void sendDirectoryListing(int const client, std::string const &dir,/*{{{*
       return;
    }
 
-   listing << "<html><head><title>Index of " << dir << "</title>"
+   listing << "<!doctype html><html><head><title>Index of " << dir << "</title><meta charset=\"utf-8\" />"
           << "<style type=\"text/css\"><!-- td {padding: 0.02em 0.5em 0.02em 0.5em;}"
           << "tr:nth-child(even){background-color:#dfdfdf;}"
           << "h1, td:nth-child(3){text-align:center;}"
@@ -359,7 +359,7 @@ static void sendDirectoryListing(int const client, std::string const &dir,/*{{{*
                 << "<td><a href=\"" << namelist[i]->d_name << "\">" << namelist[i]->d_name << "</a></td>"
                 << "<td>" << SizeToStr(fs.st_size) << "B</td>";
       }
-      listing << "<td>" << TimeRFC1123(fs.st_mtime) << "</td></tr>" << std::endl;
+      listing << "<td>" << TimeRFC1123(fs.st_mtime, true) << "</td></tr>" << std::endl;
    }
    listing << "</table></body></html>" << std::endl;
 
@@ -760,7 +760,7 @@ static void * handleClient(void * voidclient)                               /*{{{*/
                           headers.push_back(contentrange.str());
                        }
                        sendError(client, 416, *m, sendContent, "", headers);
-                       break;
+                       continue;
                     }
                  }
               }