X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/c1e7b36400db49d3dcb403512e9b009d1b6d05bc..422a2eba84361a8dfd84b549c13037512779c572:/test/interactive-helper/aptwebserver.cc diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index 3e91406ab..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) @@ -359,7 +362,7 @@ static void sendDirectoryListing(int const client, std::string const &dir,/*{{{* << "d_name << "\">" << namelist[i]->d_name << "" << "" << SizeToStr(fs.st_size) << "B"; } - listing << "" << TimeRFC1123(fs.st_mtime) << "" << std::endl; + listing << "" << TimeRFC1123(fs.st_mtime, true) << "" << std::endl; } listing << "" << std::endl; @@ -714,6 +717,15 @@ static void * handleClient(void * voidclient) /*{{{*/ condition.clear(); if (condition.empty() == false && strncmp(condition.c_str(), "bytes=", 6) == 0) { + std::string ranges = ',' + _config->Find("aptwebserver::response-header::Accept-Ranges") + ','; + ranges.erase(std::remove(ranges.begin(), ranges.end(), ' '), ranges.end()); + if (ranges.find(",bytes,") == std::string::npos) + { + // we handle it as an error here because we are a test server - a real one should just ignore it + sendError(client, 400, *m, sendContent, "Client does range requests we don't support", headers); + continue; + } + time_t cache; std::string ifrange; if (_config->FindB("aptwebserver::support::if-range", true) == true)