@@ -45,37 +45,37 @@ internal class HttpClient(
45
45
override suspend fun post (
46
46
url : String ,
47
47
body : JSONObject ,
48
- headerValues : OptionalHeaderValues ? ,
49
- ): HttpResponse = makeRequest(url, " POST" , body, _configModelStore .model.httpTimeout, headerValues )
48
+ headers : OptionalHeaders ? ,
49
+ ): HttpResponse = makeRequest(url, " POST" , body, _configModelStore .model.httpTimeout, headers )
50
50
51
51
override suspend fun get (
52
52
url : String ,
53
- headerValues : OptionalHeaderValues ? ,
54
- ): HttpResponse = makeRequest(url, null , null , _configModelStore .model.httpGetTimeout, headerValues )
53
+ headers : OptionalHeaders ? ,
54
+ ): HttpResponse = makeRequest(url, null , null , _configModelStore .model.httpGetTimeout, headers )
55
55
56
56
override suspend fun put (
57
57
url : String ,
58
58
body : JSONObject ,
59
- headerValues : OptionalHeaderValues ? ,
60
- ): HttpResponse = makeRequest(url, " PUT" , body, _configModelStore .model.httpTimeout, headerValues )
59
+ headers : OptionalHeaders ? ,
60
+ ): HttpResponse = makeRequest(url, " PUT" , body, _configModelStore .model.httpTimeout, headers )
61
61
62
62
override suspend fun patch (
63
63
url : String ,
64
64
body : JSONObject ,
65
- headerValues : OptionalHeaderValues ? ,
66
- ): HttpResponse = makeRequest(url, " PATCH" , body, _configModelStore .model.httpTimeout, headerValues )
65
+ headers : OptionalHeaders ? ,
66
+ ): HttpResponse = makeRequest(url, " PATCH" , body, _configModelStore .model.httpTimeout, headers )
67
67
68
68
override suspend fun delete (
69
69
url : String ,
70
- headerValues : OptionalHeaderValues ? ,
71
- ): HttpResponse = makeRequest(url, " DELETE" , null , _configModelStore .model.httpTimeout, headerValues )
70
+ headers : OptionalHeaders ? ,
71
+ ): HttpResponse = makeRequest(url, " DELETE" , null , _configModelStore .model.httpTimeout, headers )
72
72
73
73
private suspend fun makeRequest (
74
74
url : String ,
75
75
method : String? ,
76
76
jsonBody : JSONObject ? ,
77
77
timeout : Int ,
78
- headerValues : OptionalHeaderValues ? ,
78
+ headers : OptionalHeaders ? ,
79
79
): HttpResponse {
80
80
// If privacy consent is required but not yet given, any non-GET request should be blocked.
81
81
if (method != null && _configModelStore .model.consentRequired == true && _configModelStore .model.consentGiven != true ) {
@@ -90,7 +90,7 @@ internal class HttpClient(
90
90
91
91
try {
92
92
return withTimeout(getThreadTimeout(timeout).toLong()) {
93
- return @withTimeout makeRequestIODispatcher(url, method, jsonBody, timeout, headerValues )
93
+ return @withTimeout makeRequestIODispatcher(url, method, jsonBody, timeout, headers )
94
94
}
95
95
} catch (e: TimeoutCancellationException ) {
96
96
Logging .error(" HttpClient: Request timed out: $url " , e)
@@ -106,7 +106,7 @@ internal class HttpClient(
106
106
method : String? ,
107
107
jsonBody : JSONObject ? ,
108
108
timeout : Int ,
109
- headerValues : OptionalHeaderValues ? ,
109
+ headers : OptionalHeaders ? ,
110
110
): HttpResponse {
111
111
var retVal: HttpResponse ? = null
112
112
@@ -172,11 +172,11 @@ internal class HttpClient(
172
172
173
173
// H E A D E R S
174
174
175
- if (headerValues ?.cacheKey != null ) {
175
+ if (headers ?.cacheKey != null ) {
176
176
val eTag =
177
177
_prefs .getString(
178
178
PreferenceStores .ONESIGNAL ,
179
- PreferenceOneSignalKeys .PREFS_OS_ETAG_PREFIX + headerValues .cacheKey,
179
+ PreferenceOneSignalKeys .PREFS_OS_ETAG_PREFIX + headers .cacheKey,
180
180
)
181
181
if (eTag != null ) {
182
182
con.setRequestProperty(" If-None-Match" , eTag)
@@ -197,7 +197,7 @@ internal class HttpClient(
197
197
val cachedResponse =
198
198
_prefs .getString(
199
199
PreferenceStores .ONESIGNAL ,
200
- PreferenceOneSignalKeys .PREFS_OS_HTTP_CACHE_PREFIX + headerValues ?.cacheKey,
200
+ PreferenceOneSignalKeys .PREFS_OS_HTTP_CACHE_PREFIX + headers ?.cacheKey,
201
201
)
202
202
Logging .debug(
203
203
" HttpClient: Got Response = ${method ? : " GET" } ${con.url} - Using Cached response due to 304: " +
@@ -216,19 +216,19 @@ internal class HttpClient(
216
216
" HttpClient: Got Response = ${method ? : " GET" } ${con.url} - STATUS: $httpResponse - Body: " + json,
217
217
)
218
218
219
- if (headerValues ?.cacheKey != null ) {
219
+ if (headers ?.cacheKey != null ) {
220
220
val eTag = con.getHeaderField(" etag" )
221
221
if (eTag != null ) {
222
222
Logging .debug(" HttpClient: Got Response = Response has etag of $eTag so caching the response." )
223
223
224
224
_prefs .saveString(
225
225
PreferenceStores .ONESIGNAL ,
226
- PreferenceOneSignalKeys .PREFS_OS_ETAG_PREFIX + headerValues .cacheKey,
226
+ PreferenceOneSignalKeys .PREFS_OS_ETAG_PREFIX + headers .cacheKey,
227
227
eTag,
228
228
)
229
229
_prefs .saveString(
230
230
PreferenceStores .ONESIGNAL ,
231
- PreferenceOneSignalKeys .PREFS_OS_HTTP_CACHE_PREFIX + headerValues .cacheKey,
231
+ PreferenceOneSignalKeys .PREFS_OS_HTTP_CACHE_PREFIX + headers .cacheKey,
232
232
json,
233
233
)
234
234
}
0 commit comments