@@ -20,9 +20,10 @@ public class HTTPClient {
20
20
private var writeKeySessions = [ String: URLSession] ( )
21
21
private var apiHost : String
22
22
private var apiKey : String
23
+ private var cdnHost : String
23
24
private let analytics : Analytics
24
25
25
- init ( analytics: Analytics , apiKey: String ? = nil , apiHost: String ? = nil ) {
26
+ init ( analytics: Analytics , apiKey: String ? = nil , apiHost: String ? = nil , cdnHost : String ? = nil ) {
26
27
self . analytics = analytics
27
28
28
29
if let apiKey = apiKey {
@@ -36,6 +37,12 @@ public class HTTPClient {
36
37
} else {
37
38
self . apiHost = Self . defaultAPIHost
38
39
}
40
+
41
+ if let cdnHost = cdnHost {
42
+ self . cdnHost = cdnHost
43
+ } else {
44
+ self . cdnHost = Self . defaultCDNHost
45
+ }
39
46
}
40
47
41
48
func segmentURL( for host: String , path: String ) -> URL ? {
@@ -103,7 +110,7 @@ public class HTTPClient {
103
110
// from write key sessions for uploading.
104
111
let settingsKey = " \( writeKey) _settings "
105
112
106
- guard let settingsURL = segmentURL ( for: Self . defaultCDNHost , path: " /projects/ \( writeKey) /settings " ) else {
113
+ guard let settingsURL = segmentURL ( for: cdnHost , path: " /projects/ \( writeKey) /settings " ) else {
107
114
completion ( false , nil )
108
115
return
109
116
}
@@ -165,6 +172,10 @@ extension HTTPClient {
165
172
internal static func getDefaultAPIHost( ) -> String {
166
173
return Self . defaultAPIHost
167
174
}
175
+
176
+ internal static func getDefaultCDNHost( ) -> String {
177
+ return Self . defaultCDNHost
178
+ }
168
179
}
169
180
170
181
0 commit comments