To avoid accessing a null point, make sure result == OK before accessing the response ptr. (#1195)

This commit is contained in:
faker 2022-03-26 17:02:58 +08:00 committed by GitHub
parent dd63a72dab
commit 740c34fce3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
#include <drogon/drogon.h>
#include <iostream>
#include <future>
#include <iostream>
using namespace drogon;
@ -20,7 +21,15 @@ int main()
for (int i = 0; i < 10; ++i)
{
client->sendRequest(
req, [](ReqResult, const HttpResponsePtr &response) {
req, [](ReqResult result, const HttpResponsePtr &response) {
if (result != ReqResult::Ok)
{
std::cout
<< "error while sending request to server! result: "
<< result << std::endl;
return;
}
std::cout << "receive response!" << std::endl;
// auto headers=response.
++nth_resp;