-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathHttpClientFactory.cpp
More file actions
83 lines (71 loc) · 2.47 KB
/
HttpClientFactory.cpp
File metadata and controls
83 lines (71 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
#include "mat/config.h"
#ifdef HAVE_MAT_DEFAULT_HTTP_CLIENT
#include "HttpClientFactory.hpp"
#include "pal/PAL.hpp"
#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#endif
#if defined(MATSDK_PAL_WIN32)
#ifdef _WINRT_DLL
#include "http/HttpClient_WinRt.hpp"
#elif defined(HAVE_MAT_WININET_HTTP_CLIENT)
#include "http/HttpClient_WinInet.hpp"
#endif
#elif defined(MATSDK_PAL_CPP11)
#if TARGET_OS_IPHONE || (defined(__APPLE__) && defined(APPLE_HTTP))
#include "http/HttpClient_Apple.hpp"
#elif defined(HAVE_MAT_CURL_HTTP_CLIENT) || !defined(ANDROID)
#include "http/HttpClient_Curl.hpp"
#elif defined(ANDROID)
#include "http/HttpClient_Android.hpp"
#endif
#else
#error The library cannot work without an HTTP client implementation.
#endif
namespace MAT_NS_BEGIN {
MATSDK_LOG_INST_COMPONENT_CLASS(HttpClientFactory, "EventsSDK.HttpClientFactory", "Events telemetry client - HttpClientFactory class")
#if defined(MATSDK_PAL_WIN32)
#ifdef _WINRT_DLL
/* Win 10 HTTP client */
std::shared_ptr<IHttpClient> HttpClientFactory::Create() {
LOG_TRACE("Creating HttpClient_WinRt");
return std::make_shared<HttpClient_WinRt>();
}
#elif defined(HAVE_MAT_WININET_HTTP_CLIENT)
/* Win32 WinInet HTTP client */
std::shared_ptr<IHttpClient> HttpClientFactory::Create() {
LOG_TRACE("Creating HttpClient_WinInet");
return std::make_shared<HttpClient_WinInet>();
}
#endif
#elif defined(HAVE_MAT_CURL_HTTP_CLIENT)
std::shared_ptr<IHttpClient> HttpClientFactory::Create() {
LOG_TRACE("Creating HttpClient_Curl");
return std::make_shared<HttpClient_Curl>();
}
#elif defined(MATSDK_PAL_CPP11)
#if TARGET_OS_IPHONE || (defined(__APPLE__) && defined(APPLE_HTTP))
std::shared_ptr<IHttpClient> HttpClientFactory::Create() {
LOG_TRACE("Creating HttpClient_Apple");
return std::make_shared<HttpClient_Apple>();
}
#elif defined(ANDROID)
std::shared_ptr<IHttpClient> HttpClientFactory::Create() {
LOG_TRACE("Creating HttpClient_Android");
return HttpClient_Android::GetClientInstance();
}
#else
std::shared_ptr<IHttpClient> HttpClientFactory::Create() {
LOG_TRACE("Creating HttpClient_Curl");
return std::make_shared<HttpClient_Curl>();
}
#endif
#else
#error The library cannot work without an HTTP client implementation.
#endif
} MAT_NS_END
#endif