diff --git a/drogon_ctl/press.cc b/drogon_ctl/press.cc index 96d0fb8e..3dc424b8 100644 --- a/drogon_ctl/press.cc +++ b/drogon_ctl/press.cc @@ -18,7 +18,7 @@ #include #include #include -#include +#include #ifndef _WIN32 #include #endif @@ -32,8 +32,8 @@ std::string press::detail() " -n num number of requests(default : 1)\n" " -t num number of threads(default : 1)\n" " -c num concurrent connections(default : 1)\n" - // " -k keep alive(default: no)\n" - " -q no progress indication(default: no)\n\n" + " -k disable SSL certificate validation(default: enable)\n" + " -q no progress indication(default: show)\n\n" "example: drogon_ctl press -n 10000 -c 100 -t 4 -q " "http://localhost:8080/index.html\n"; } @@ -151,11 +151,11 @@ void press::handleCommand(std::vector ¶meters) continue; } } - // else if (param == "-k") - // { - // keepAlive_ = true; - // continue; - // } + else if (param == "-k") + { + certValidation_ = false; + continue; + } else if (param == "-q") { processIndication_ = false; @@ -178,7 +178,7 @@ void press::handleCommand(std::vector ¶meters) else { auto pos = url_.find("://"); - auto posOfPath = url_.find("/", pos + 3); + auto posOfPath = url_.find('/', pos + 3); if (posOfPath == std::string::npos) { host_ = url_; @@ -216,8 +216,10 @@ void press::createRequestAndClients() loopPool_->start(); for (size_t i = 0; i < numOfConnections_; ++i) { - auto client = - HttpClient::newHttpClient(host_, loopPool_->getNextLoop()); + auto client = HttpClient::newHttpClient(host_, + loopPool_->getNextLoop(), + false, + certValidation_); client->enableCookies(); clients_.push_back(client); } @@ -284,7 +286,6 @@ void press::sendRequest(const HttpClientPtr &client) void press::outputResults() { - static std::mutex mtx; size_t totalSent = 0; size_t totalRecv = 0; for (auto &client : clients_) @@ -296,7 +297,7 @@ void press::outputResults() auto microSecs = now.microSecondsSinceEpoch() - statistics_.startDate_.microSecondsSinceEpoch(); double seconds = (double)microSecs / 1000000.0; - size_t rps = static_cast(statistics_.numOfGoodResponse_ / seconds); + auto rps = static_cast(statistics_.numOfGoodResponse_ / seconds); std::cout << std::endl; std::cout << "TOTALS: " << numOfConnections_ << " connect, " << numOfRequests_ << " requests, " diff --git a/drogon_ctl/press.h b/drogon_ctl/press.h index cb65030a..77c67ccd 100644 --- a/drogon_ctl/press.h +++ b/drogon_ctl/press.h @@ -62,7 +62,7 @@ class press : public DrObject, public CommandHandler size_t numOfThreads_{1}; size_t numOfRequests_{1}; size_t numOfConnections_{1}; - // bool keepAlive_ = false; + bool certValidation_{true}; bool processIndication_{true}; std::string url_; std::string host_; diff --git a/lib/src/HttpClientImpl.cc b/lib/src/HttpClientImpl.cc index ac2716d7..814b30e5 100644 --- a/lib/src/HttpClientImpl.cc +++ b/lib/src/HttpClientImpl.cc @@ -639,6 +639,7 @@ void HttpClientImpl::onRecvMessage(const trantor::TcpConnectionPtr &connPtr, } else { + bytesReceived_ += (msgSize - msg->readableBytes()); break; } }