Skip to content

Commit 4132dda

Browse files
committed
remove auth headers from httprequest tostring
1 parent 6359f9f commit 4132dda

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/commonMain/kotlin/com.adamratzman.spotify/http/HttpRequest.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,16 @@ public class HttpRequest constructor(
243243
}
244244

245245
override fun toString(): String {
246-
return """HttpConnection (
246+
// we don't want to print this sensitive information
247+
val headersWithoutAuthorization = headers.filter { it.key != "Authorization" }
248+
val hasAuthorizationHeader = headersWithoutAuthorization.size != headers.size
249+
return """HttpConnection(
247250
|url=$url,
248251
|method=$method,
249252
|body=${bodyString ?: bodyMap},
250253
|contentType=$contentType,
251-
|headers=${headers.toList()}
252-
| )
254+
|headers=${headersWithoutAuthorization.toList()}
255+
|${if (hasAuthorizationHeader) "The authorization header was hidden." else "There was no authorization header."})
253256
""".trimMargin()
254257
}
255258

0 commit comments

Comments
 (0)