From c6cacef907a5039ed029e1e26204aaba8e698aaa Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 5 Jun 2024 17:29:20 +0200 Subject: [PATCH] fix: Set body for all eligible request methods --- .../configuration/services/OldApiService.kt | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/app/revanced/api/configuration/services/OldApiService.kt b/src/main/kotlin/app/revanced/api/configuration/services/OldApiService.kt index ea15427..2c464aa 100644 --- a/src/main/kotlin/app/revanced/api/configuration/services/OldApiService.kt +++ b/src/main/kotlin/app/revanced/api/configuration/services/OldApiService.kt @@ -25,20 +25,21 @@ internal class OldApiService(private val client: HttpClient) { headers { appendAll( call.request.headers.filter { key, _ -> - !key.equals( - HttpHeaders.ContentType, - ignoreCase = true, - ) && - !key.equals( - HttpHeaders.ContentLength, - ignoreCase = true, - ) && - !key.equals(HttpHeaders.Host, ignoreCase = true) + !( + key.equals(HttpHeaders.ContentType, ignoreCase = true) || + key.equals(HttpHeaders.ContentLength, ignoreCase = true) || + key.equals(HttpHeaders.Host, ignoreCase = true) + ) }, ) } - if (call.request.httpMethod == HttpMethod.Post) { - body = ByteArrayContent(byteArray, call.request.contentType()) + + when (call.request.httpMethod) { + HttpMethod.Post, + HttpMethod.Put, + HttpMethod.Patch, + HttpMethod.Delete, + -> body = ByteArrayContent(byteArray, call.request.contentType()) } }