Use unique_ref instead of unique_ptr
This commit is contained in:
parent
a537979d23
commit
4ed555b422
@ -211,13 +211,13 @@ namespace cpputils {
|
||||
};
|
||||
|
||||
namespace {
|
||||
std::unique_ptr<WinHttpSession> create_session() {
|
||||
cpputils::unique_ref<WinHttpSession> create_session() {
|
||||
HttpHandleRAII session_handle = WinHttpOpen(L"cpputils::HttpClient", WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
|
||||
if(nullptr == session_handle.handle) {
|
||||
throw std::runtime_error("Error calling WinHttpOpen. Error code: " + std::to_string(GetLastError()));
|
||||
}
|
||||
|
||||
return std::make_unique<WinHttpSession>(std::move(session_handle));
|
||||
return cpputils::make_unique<_refWinHttpSession>(std::move(session_handle));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "HttpClient.h"
|
||||
#include "../macros.h"
|
||||
#include "../pointer/unique_ref.h"
|
||||
|
||||
namespace cpputils {
|
||||
|
||||
@ -19,7 +20,7 @@ namespace cpputils {
|
||||
std::string get(const std::string &url, boost::optional<long> timeoutMsec = boost::none) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<WinHttpSession> session_;
|
||||
unique_ref<WinHttpSession> session_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WinHttpClient);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user