【发布时间】:2019-09-16 05:45:42
【问题描述】:
我遇到过这样的问题:似乎我的服务器在超时或客户端返回一些错误后收到了来自客户端的http请求。 我想知道我的服务器是否有可能在超时后接收到 http 请求? 我在客户端的代码:
while(1)
{
std::cout << "=====post once>>>>>>>>>>>" << std::endl;
auto res = Post(route.c_str(), content, "text/plain");
if((res == nullptr) || (res->status != 200))
sleep(3);
else
{
if (res) {
// std::cout << res->status << std::endl;
std::cout << res->body << std::endl;
}
break;
}
}
我将在超时或错误请求后重试发布。在某些情况下,WIFI 很差,服务器会在很短的时间内收到两个 http 帖子。似乎一个 http 请求在发生错误或超时或类似情况后首先到达服务器,然后另一个 http 请求到达服务器,因为 while(1). 谁能回答我的问题?谢谢
【问题讨论】: