Skip to content

Commit 2083bd0

Browse files
author
Rodrigo Gomez Palacio
committed
Update HttpClient to put new optional headers into request
Motivation: offset, secondsSinceAppOpen, & retryCount will be sent as headers
1 parent 5b83545 commit 2083bd0

File tree

1 file changed

+14
-2
lines changed
  • OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/http/impl

1 file changed

+14
-2
lines changed

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/http/impl/HttpClient.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,18 @@ internal class HttpClient(
184184
}
185185
}
186186

187+
if (headers?.rywToken != null) {
188+
con.setRequestProperty("OneSignal-RYW-Token", headers.rywToken.toString())
189+
}
190+
191+
if (headers?.retryCount != null) {
192+
con.setRequestProperty("Onesignal-Retry-Count", headers.retryCount.toString())
193+
}
194+
195+
if (headers?.sessionDuration != null) {
196+
con.setRequestProperty("OneSignal-Session-Duration", headers.sessionDuration.toString())
197+
}
198+
187199
// Network request is made from getResponseCode()
188200
httpResponse = con.responseCode
189201

@@ -299,9 +311,9 @@ internal class HttpClient(
299311
* Reads the HTTP Retry-Limit from the response.
300312
*/
301313
private fun retryLimitFromResponse(con: HttpURLConnection): Int? {
302-
val retryLimitStr = con.getHeaderField("Retry-Limit")
314+
val retryLimitStr = con.getHeaderField("OneSignal-Retry-Limit")
303315
return if (retryLimitStr != null) {
304-
Logging.debug("HttpClient: Response Retry-After: $retryLimitStr")
316+
Logging.debug("HttpClient: Response OneSignal-Retry-Limit: $retryLimitStr")
305317
retryLimitStr.toIntOrNull()
306318
} else {
307319
null

0 commit comments

Comments
 (0)