Skip to content

Commit

Permalink
KTOR-5300 Disable body length check for JS Browser target (ktorio#3315)
Browse files Browse the repository at this point in the history
Some browsers do not expose `Content-Encoding` header
https://youtrack.jetbrains.com/issue/KTOR-5300
  • Loading branch information
rsinukov authored and Rattenkrieg committed Jan 5, 2023
1 parent df75cfc commit 4ba6973
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -77,8 +77,8 @@ public fun HttpClient.defaultTransformers() {
val bytes = body.toByteArray()

val contentLength = response.contentLength()
val contentEncoding = response.headers[HttpHeaders.ContentEncoding]
if (contentEncoding == null && contentLength != null && contentLength > 0) {
val notEncoded = !PlatformUtils.IS_BROWSER && response.headers[HttpHeaders.ContentEncoding] == null
if (notEncoded && contentLength != null && contentLength > 0) {
check(bytes.size == contentLength.toInt()) { "Expected $contentLength, actual ${bytes.size}" }
}
proceedWith(HttpResponseContainer(info, bytes))
Expand Down

0 comments on commit 4ba6973

Please sign in to comment.