From 3966de8e718649870270d5cbdf671b395bfc0dcc Mon Sep 17 00:00:00 2001 From: randomdan Date: Sat, 26 Jan 2013 01:18:05 +0000 Subject: Allow reading URL list from a file for bulk testing --- project2/cgi/testCgi.cpp | 19 +++++++++++++++++-- 1 file 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 -- cgit v1.2.3