0

I have this basic http_request performing correctly. I receive the 200 OK status code and respective body correctly, for all the times I perform a request (I even tried to perform several requests before leaving the application). The problem is that I always receive a SIGSEV before the application return with the message:

"Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)"

Any clue of what could be causing this?

#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;
}
José Silva
  • 47
  • 1
  • 10
  • 2
    Looking at the docs ( https://microsoft.github.io/cpprestsdk/classweb_1_1http_1_1client_1_1http__client.html )`request` is async - so the program execution continues and everything is left hanging before the lamba is executed. – Richard Critten Jan 08 '18 at 11:08
  • Thanks, @RichardCritten, editing the code sample I deleted the last instruction of lambda function, which is ".wait()". Even with the ".wait()" instruction, do you think this should happen? I appreciate any help on this one. – José Silva Jan 08 '18 at 11:56
  • Please use a debugger to find out **where** is the program crashing and provide this information in your question. – r3mus n0x Jun 26 '18 at 16:43

0 Answers0