Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,20 @@ if(NOT MATSDK_USE_VCPKG_DEPS)
endif()
add_definitions(-D_UNICODE -DUNICODE -DWIN32 -DMATSDK_PLATFORM_WINDOWS=1 -D_UTC_SDK -DUSE_BOND -D_WINDOWS -D_USRDLL -DWINVER=_WIN32_WINNT_WIN7)
remove_definitions(-D_MBCS)
# WinHTTP is the default Win32 desktop HTTP transport (see
# HttpClientFactory.hpp): unlike WinInet it does not require a logged-on
# interactive user, so it works in services and other non-interactive
# processes. Set MATSDK_USE_WININET=ON to opt back into WinInet, e.g. for
# IE-integrated proxy/cookie behavior.
option(MATSDK_USE_WININET "Use WinInet instead of WinHTTP as the Win32 desktop HTTP client" OFF)
if(MATSDK_USE_WININET)
add_definitions(-DHAVE_MAT_WININET_HTTP_CLIENT)
endif()
list(APPEND SRCS
http/HttpClient_WinInet.cpp
http/HttpClient_WinInet.hpp
http/HttpClient_WinHttp.cpp
http/HttpClient_WinHttp.hpp
pal/desktop/WindowsDesktopDeviceInformationImpl.cpp
pal/desktop/WindowsDesktopNetworkInformationImpl.cpp
pal/desktop/WindowsDesktopSystemInformationImpl.cpp
Expand Down Expand Up @@ -606,7 +617,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
target_link_libraries(mat PUBLIC log)
endif()
elseif(PAL_IMPLEMENTATION STREQUAL "WIN32")
target_link_libraries(mat PUBLIC wininet crypt32 ws2_32)
target_link_libraries(mat PUBLIC wininet winhttp crypt32 ws2_32)
elseif(APPLE)
target_link_libraries(mat PUBLIC
"-framework CoreFoundation"
Expand Down
9 changes: 9 additions & 0 deletions lib/http/HttpClientFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "http/HttpClient_WinRt.hpp"
#elif defined(HAVE_MAT_WININET_HTTP_CLIENT)
#include "http/HttpClient_WinInet.hpp"
#elif defined(HAVE_MAT_WINHTTP_HTTP_CLIENT)
#include "http/HttpClient_WinHttp.hpp"
#endif
#elif defined(MATSDK_PAL_CPP11)
#if TARGET_OS_IPHONE || (defined(__APPLE__) && defined(APPLE_HTTP))
Expand Down Expand Up @@ -49,6 +51,13 @@ namespace MAT_NS_BEGIN {
return std::make_shared<HttpClient_WinInet>();
}

#elif defined(HAVE_MAT_WINHTTP_HTTP_CLIENT)
/* Win32 WinHTTP client (default) */
std::shared_ptr<IHttpClient> HttpClientFactory::Create() {
LOG_TRACE("Creating HttpClient_WinHttp");
return std::make_shared<HttpClient_WinHttp>();
}

#endif
#elif defined(HAVE_MAT_CURL_HTTP_CLIENT)
std::shared_ptr<IHttpClient> HttpClientFactory::Create() {
Expand Down
13 changes: 11 additions & 2 deletions lib/http/HttpClientFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,17 @@ class HttpClientFactory

// TODO: [maxgolov] - remove this once there is a better way to pass HTTP client configuration
#if defined(MATSDK_PAL_WIN32) && !defined(_WINRT_DLL)
#define HAVE_MAT_WININET_HTTP_CLIENT
#include "http/HttpClient_WinInet.hpp"
#if defined(HAVE_MAT_WININET_HTTP_CLIENT)
#include "http/HttpClient_WinInet.hpp"
#else
// WinHTTP is the default Win32 desktop transport: unlike WinInet, it does
// not depend on a logged-on interactive user or that user's Internet
// Explorer settings, so it works in services and other non-interactive
// processes without extra configuration. Define HAVE_MAT_WININET_HTTP_CLIENT
// to opt back into WinInet (e.g. for IE-integrated proxy/cookie behavior).
#define HAVE_MAT_WINHTTP_HTTP_CLIENT
#include "http/HttpClient_WinHttp.hpp"
#endif
#endif

#endif // HAVE_MAT_DEFAULT_HTTP_CLIENT
Expand Down
Loading
Loading