From 4437cd622b4c375c8519b05f0cc7c31db5d622c9 Mon Sep 17 00:00:00 2001 From: Lochlan Date: Fri, 28 Jun 2019 20:41:44 +1000 Subject: [PATCH] fix(android): ignore gzip content-encoding for 204 statusCode (#7417) --- .../src/main/java/org/nativescript/widgets/Async.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/Async.java b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/Async.java index 5ed78364f..bc1eb8ec1 100644 --- a/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/Async.java +++ b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/Async.java @@ -409,8 +409,9 @@ public class Async { // In the event we don't have a null stream, and we have gzip as part of the encoding // then we will use gzip to decode the stream + // Ignore gzip encoding for 204 'No Content' status to prevent java.io.EOFException String encodingHeader = connection.getHeaderField("Content-Encoding"); - if (encodingHeader != null && encodingHeader.toLowerCase().contains("gzip")) { + if (encodingHeader != null && encodingHeader.toLowerCase().contains("gzip") && this.statusCode != 204) { inStream = new GZIPInputStream(inStream); } @@ -584,4 +585,4 @@ public class Async { } } } -} \ No newline at end of file +}