Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/main/kotlin/io/github/vxrpenter/secretlab/SecretLab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ class SecretLab(private val apiKey: String, private val accountId: String, readT

try {
client.newCall(request).execute().use { response ->
logCall(request.url.toString(), response.isSuccessful, response.code, response.message)
val obj = Json.decodeFromString<ServerInfo>(response.body!!.string())
logCall(request.url.toString().replace(apiKey, "keyRemovedForPrivacyReasons"), response.isSuccessful, response.code, response.message)
val responseBody = response.body!!.string().replace("\"Nickname\":false", "\"Nickname\":\"Could not fetch\"")
val obj = Json.decodeFromString<ServerInfo>(responseBody)

obj.response = getResponseTime(response)
return obj
}
} catch (e: Exception) {
throw CallFailureException("Failed to get server info from ${request.url}", e)
}
catch (e: Exception) {
throw CallFailureException("Failed to get server info from ${request.url.toString().replace(apiKey, "keyRemovedForPrivacyReasons")}", e)
}
}

Expand Down Expand Up @@ -77,6 +79,8 @@ class SecretLab(private val apiKey: String, private val accountId: String, readT
return (received-sent)
}



private fun logCall(requestUrl: String, successful: Boolean, exitCode: Int, statusMessage: String) {
if (successful) {
logger.debug("Request to $requestUrl was successful with exitcode $exitCode $statusMessage")
Expand Down