服务器边缘测试与性能测试
1. 长连接连续请求测试
长连接测试 1:创建一个客户端持续给服务器发送数据,直到超过超时时间看看是否正常。
#include "httpserver.hpp"
#define WWWROOT "./wwwroot"
std::string RequestStr(const HttpRequest &req) {
std::stringstream ss;
ss << req._method << " " << req._path << " " << req._version << "\r\n";
for(auto&it : req._params){
ss << it.first << ": " << it.second << "\r\n";
}
for(auto&it : req._headers){
ss << it.first << ": " << it.second << "\r\n";
}
ss << "\r\n";
ss << req._body;
return ss.str();
}
void Hello(const HttpRequest &req, HttpResponse *rsp){
rsp->SetContent(RequestStr(req), "text/plain");
//sleep(15);
}
void Login(const HttpRequest &req, HttpResponse *rsp){
rsp->SetContent(RequestStr(req), "text/plain");
}
void PutFile(const HttpRequest &req, HttpResponse *rsp){
std::string path = WWWROOT + req._path;
Until::(path, req._body);
}
{
rsp->((req), );
}
{
;
server.();
server.(WWWROOT);
server.(, Hello);
server.(, Login);
server.(, PutFile);
server.(, DelFile);
server.();
;
}


