我已正确执行此基本http_request。我总是正确地收到200 OK状态代码和相应的正文,我一直在执行请求(我甚至试图在离开应用程序之前执行多个请求)。 问题是我总是在应用程序返回之前收到SIGSEV并显示消息:
“处理以退出代码139结束(由信号11:SIGSEGV中断)”
任何可能导致此问题的线索?
#include <iostream>
#include <cpprest/http_client.h>
#include <thread>
main(){
const std::string URI = "https://192.168.13.141/v1/testing/stats/add";
//Defining configuration to accept self signed certificates
http_client_config config;
config.set_validate_certificates(false);
//Creating the client
http_client client(U(newURI),config);
//The auth token
const std::string token = "Bearer testToken";
const std::string authTag = "Authorization";
//Creating the request
http_request request;
request.headers().add(authTag,token);
request.set_method(methods::GET);
client.request(request).then([](http_response response) {
if(response.status_code() == status_codes::OK) {
std::cout << response.to_string() << std::endl;
}else{
std::cout << response.to_string() << std::endl;
}
}).wait();
return 0;
}