diff options
-rw-r--r-- | project2/cgi/testCgi.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/project2/cgi/testCgi.cpp b/project2/cgi/testCgi.cpp index 8cf5606..6dc2193 100644 --- a/project2/cgi/testCgi.cpp +++ b/project2/cgi/testCgi.cpp @@ -58,6 +58,7 @@ class TestInput : public cgicc::CgiInput, public CgiEnvInput { TESTOPT("HTTP_COOKIE", "", "Cookie") TESTOPT("HTTPS", "No", "HTTPS?") TESTOPT("HTTP_IF_MODIFIED_SINCE", "", "Client cached copy timestamp") + ("urlListFile", Options::value(&urlListFile, ""), "Load URL list from this file") ("runCount", Options::value(&runCount, 1), "Repeat run this many times") ; FileOptions fo(".testCgi.settings"); @@ -81,8 +82,21 @@ class TestInput : public cgicc::CgiInput, public CgiEnvInput { } void run() { - for (int run = 0; run < runCount; run += 1) { - cgiServe(this, &env, std::cout, this); + if (urlListFile.empty()) { + for (int run = 0; run < runCount; run += 1) { + cgiServe(this, &env, std::cout, this); + } + } + else { + for (int run = 0; run < runCount; run += 1) { + std::ifstream urls(urlListFile); + while (!urls.eof()) { + std::string url; + urls >> url; + optStore["REDIRECT_URL"] = StrPtr(new std::string(url)); + cgiServe(this, &env, std::cout, this); + } + } } } @@ -90,6 +104,7 @@ class TestInput : public cgicc::CgiInput, public CgiEnvInput { CgiEnvironment env; Options opts; int runCount; + std::string urlListFile; }; int |