microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.96k stars 1.65k forks source link

Visual Studio 2019:Exception after the creation of an instance of http::experimental::listener::http_listener #1690

Closed uweziegler closed 2 years ago

uweziegler commented 2 years ago

I am using the your CppRestApi in the version 2.10.5 from 28.3.2020. Unfortunately, an error occurs during the creation of an instance of http::experimental::listener::http_listener. The following lines will be describe that exeption. A simple C++ Project is attached. In the original sample for a OAuth2 Authentification from Microsoft at : https://github.com/Microsoft/cpprestsdk/blob/master/Release/samples/Oauth2Client/Oauth2Client.cpp or: https://github.com/Microsoft/cpprestsdk/wiki occurs the same error. I noticed more than 4 Exeptions.. regards 

// This is the redirected URL supposed by OPM 
// in the case of a desktop applicaton.
// ( https://www.openproject.org/docs/api/example/ )
const WCHAR url[] = L"urn:ietf:wg:oauth:2.0:oob";

web::uri uri(url);

// I create a default listener config
http_listener_config* pconfig = new http_listener_config();
assert(pconfig);

// This is the pointer for the instance of the http_listener
http_listener* plistener = nullptr;

// That works, but it is a dummy, not useable.
plistener = new http_listener();
assert(plistener);
if (plistener) {
    delete plistener;
    plistener = nullptr;
}

// That throws an exeption, the instance will not created.
plistener = new http_listener(uri);
assert(plistener);
if (plistener) {
    delete plistener;
    plistener = nullptr;
}

Exeption in asyncrt_utils.h at line 409 template<typename _Type, typename _Arg1> std::unique_ptr<_Type> make_unique(_Arg1&& arg1) { 409 return std::unique_ptr<_Type>(new _Type(std::forward<_Arg1>(arg1))); }

uweziegler commented 2 years ago

The url "urn:ietf:wg:oauth:2.0:oob" does not have a http or https !