Skip to content

Commit

Permalink
Update HttpClient to put new optional headers into request
Browse files Browse the repository at this point in the history
Motivation: offset, secondsSinceAppOpen, & retryCount will be sent as headers
  • Loading branch information
rgomezp committed Sep 24, 2024
1 parent 9509689 commit f5a6a2b
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ internal class HttpClient(
}
}

if (headers?.rywToken != null) {
con.setRequestProperty("OneSignal-RYW-Token", headers.rywToken.toString())
}

if (headers?.retryCount != null) {
con.setRequestProperty("Onesignal-Retry-Count", headers.retryCount.toString())
}

if (headers?.sessionDuration != null) {
con.setRequestProperty("OneSignal-Session-Duration", headers.sessionDuration.toString())
}

// Network request is made from getResponseCode()
httpResponse = con.responseCode

Expand Down Expand Up @@ -299,9 +311,9 @@ internal class HttpClient(
* Reads the HTTP Retry-Limit from the response.
*/
private fun retryLimitFromResponse(con: HttpURLConnection): Int? {
val retryLimitStr = con.getHeaderField("Retry-Limit")
val retryLimitStr = con.getHeaderField("OneSignal-Retry-Limit")
return if (retryLimitStr != null) {
Logging.debug("HttpClient: Response Retry-After: $retryLimitStr")
Logging.debug("HttpClient: Response OneSignal-Retry-Limit: $retryLimitStr")
retryLimitStr.toIntOrNull()
} else {
null
Expand Down

0 comments on commit f5a6a2b

Please sign in to comment.