diff options
Diffstat (limited to 'test/interactive-helper/aptwebserver.cc')
-rw-r--r-- | test/interactive-helper/aptwebserver.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index a8d191d0e..dc17d4991 100644 --- a/test/interactive-helper/aptwebserver.cc +++ b/test/interactive-helper/aptwebserver.cc @@ -341,6 +341,8 @@ bool parseFirstLine(int const client, std::string const &request, /*{{{*/ int main(int const argc, const char * argv[]) { CommandLine::Args Args[] = { + {0, "simulate-paywall", "aptwebserver::Simulate-Paywall", + CommandLine::Boolean}, {0, "port", "aptwebserver::port", CommandLine::HasArg}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, @@ -365,7 +367,9 @@ int main(int const argc, const char * argv[]) return 1; } + // get the port int const port = _config->FindI("aptwebserver::port", 8080); + bool const simulate_broken_server = _config->FindB("aptwebserver::Simulate-Paywall", false); // ensure that we accept all connections: v4 or v6 int const iponly = 0; @@ -422,8 +426,12 @@ int main(int const argc, const char * argv[]) } } - std::clog << "Serving ANY file on port: " << port << std::endl; - + if (simulate_broken_server) { + std::clog << "Simulating a broken web server that return nonsense " + "for all querries" << std::endl; + } else { + std::clog << "Serving ANY file on port: " << port << std::endl; + } listen(sock, 1); /*}}}*/ @@ -455,6 +463,14 @@ int main(int const argc, const char * argv[]) continue; } + if (simulate_broken_server == true) { + std::string data("ni ni ni\n"); + addDataHeaders(headers, data); + sendHead(client, 200, headers); + sendData(client, data); + continue; + } + // string replacements in the requested filename ::Configuration::Item const *Replaces = _config->Tree("aptwebserver::redirect::replace"); if (Replaces != NULL) |